通过此设置,我得到了一个奇怪的命名助手:
在 config/routes.rb 中我有:
Qtl::Application.routes.draw do
resources :qtl_table do
collection do
get 'search'
end
end
...
end
rake 路线输出如下:
search_qtl_table_index GET /qtl_table/search(.:format) {:action=>"search", :controller=>"qtl_table"}
qtl_table_index GET /qtl_table(.:format) {:action=>"index", :controller=>"qtl_table"}
POST /qtl_table(.:format) {:action=>"create", :controller=>"qtl_table"}
new_qtl_table GET /qtl_table/new(.:format) {:action=>"new", :controller=>"qtl_table"}
edit_qtl_table GET /qtl_table/:id/edit(.:format) {:action=>"edit", :controller=>"qtl_table"}
qtl_table GET /qtl_table/:id(.:format) {:action=>"show", :controller=>"qtl_table"}
PUT /qtl_table/:id(.:format) {:action=>"update", :controller=>"qtl_table"}
DELETE /qtl_table/:id(.:format) {:action=>"destroy", :controller=>"qtl_table"}
我确实关闭了复数:
ActiveRecord::Base.pluralize_table_names = false
但我收到此错误:
undefined local variable or method `search_qtl_table_index' for #<#<Class:0x8056a3fa8>:0x8056a2338>
这与我将很快删除的这个问题相关:Rails:路由和路径助手 https://stackoverflow.com/questions/8729125/rails-routing-and-path-helpers/8729194#8729194
这与复数无关。你需要使用search_qtl_table_index_path
当你引用它而不仅仅是search_qtl_table_index
(您需要添加_path
到最后)。
所以,你的form_tag
声明应该是:
<%= form_tag search_qtl_table_index_path, :method => 'get' do %>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)