【发布时间】:2011-08-23 05:15:29
【问题描述】:
在我的 routes.rb 中我有:
resources :fire_preventions do
get 'search_adv', :on => :collection
end
如何将它与继承的资源路由一起使用?
search_adv_collection_url 不起作用。
【问题讨论】:
标签: ruby-on-rails inherited-resources
在我的 routes.rb 中我有:
resources :fire_preventions do
get 'search_adv', :on => :collection
end
如何将它与继承的资源路由一起使用?
search_adv_collection_url 不起作用。
【问题讨论】:
标签: ruby-on-rails inherited-resources
由于只列出了一条路线,
resources :fire_preventions do
get 'search_adv', :on => :collection
end
是去掉附加块的缩写形式
resources :fire_preventions do
collection do
get 'search_adv'
end
end
您应该可以使用search_adv_fire_preventions_path 和search_adv_fire_preventions_url。最好执行rake routes 来检查。
【讨论】:
collection_url 助手是上下文相关的。另外,如果你还没有看到这个screencast。
您可以在命令行中执行rake routes。它将根据 routes.rb 打印所有可用路径
【讨论】: