我有一个 has_one 关系:
# supplier.rb
has_one :presentation
...
# presentation.rb
belongs_to :supplier
...
以及它们的以下嵌套路由:
# routes.rb
resources :suppliers do
resource :presentation
end
运行rake routes
给出:
supplier_presentation POST ... {:action=>"create", :controller=>"presentations"}
new_supplier_presentation GET ... {:action=>"new", :controller=>"presentations"}
edit_supplier_presentation GET ... {:action=>"edit", :controller=>"presentations"}
GET ... {:action=>"show", :controller=>"presentations"}
PUT ... {:action=>"update", :controller=>"presentations"}
DELETE ... {:action=>"destroy", :controller=>"presentations"}
为什么 show 动作没有 name_helper?
我可以通过以下方式覆盖问题:
resources :suppliers do
resource :presentation, :except => :show do
get "" => "presentations#show", as: "presentation"
end
end
给出路线:
presentation_supplier_presentation GET ... {:controller=>"presentations", :action=>"show"}
但我们现在都不是处理它的正确方法..
有什么建议么?
--
(已编辑)
supplier_presentation_path(@supplier)
确实有效,但为什么呢?rake routes
...在我的外壳上执行时没有出现...