I’ve added a method to my controller and routed it correctly but when I try to call it from a form_tag it give me a router error. What’s going on?
<% form_tag search_item_path, :method => 'get' do %>
<%= text_field_tag :name , '' %>
<%= submit_tag "Submit" %>
<% end %>
routes:
resources :items do
collection do
get :search, :as => :search
end
end
rake routes also ok:
search_item GET /items/:id/search(.:format) {:action=>"search", :controller=>"items"}
items GET /items(.:format) {:action=>"index", :controller=>"items"}
POST /items(.:format) {:action=>"create", :controller=>"items"}
new_item GET /items/new(.:format) {:action=>"new", :controller=>"items"}
edit_item GET /items/:id/edit(.:format) {:action=>"edit", :controller=>"items"}
item GET /items/:id(.:format) {:action=>"show", :controller=>"items"}
PUT /items/:id(.:format) {:action=>"update", :controller=>"items"}
DELETE /items/:id(.:format) {:action=>"destroy", :controller=>"items
However, if I write something like this works:
<% form_tag url_for(:controller => "items" , :action => "search"), :method => "get" do %>
What am I missing here?
I believe it should be pluralized
search_items_pathAnd routes could be little cleaner
or