这有点难以沟通,但我会尝试不粘贴所有代码。我的会员有一个邮箱,里面有很多收据。在标题布局中,我有一个调用的导航
<%= link_to "Message Center", member_mailbox_path(current_user.member_id) %>
它适用于大多数页面,例如 trails/# ,各种模型的资源页面但在其他页面上,似乎是自定义路由页面,我收到此错误
No route matches {:action=>"show", :controller=>"mailbox", :member_id=>16}
运行 rake 路线显示了这一点:
member_mailbox GET /members/:member_id/mailbox/:id(.:format) mailbox#show
路线让我感到困惑,这是我解决此问题的路线(尚未测试显示消息)...
resources :members do
resources :mailbox do
resources :receipts do
member do
get :show_message
end
end
end
end
显示错误的页面的路线与此类似
match '/my_plays', :to => "trails#my_plays"
match '/my_creations', :to => "trails#my_creations"
所以不确定我的路线是否正确。我想知道资源 :mailbox 是否正确,因为我没有大量资源,它是 has_one .... THX
----编辑---根据建议更改路线后:
member_mailbox POST /members/:member_id/mailbox(.:format) mailboxes#create
new_member_mailbox GET /members/:member_id/mailbox/new(.:format) mailboxes#new
edit_member_mailbox GET /members/:member_id/mailbox/edit(.:format) mailboxes#edit
GET /members/:member_id/mailbox(.:format) mailboxes#show
PUT /members/:member_id/mailbox(.:format) mailboxes#update
DELETE /members/:member_id/mailbox(.:format) mailboxes#destroy