i was wondering why does
<%= form_tag( { :action => "/search", :method => "get" }, :class => "span4" ) do %>
...
<% end %>
give the following error?
No route matches [POST] "/assets"
i notice it’s because of the /search. if i rewrote the code as…
<%= form_tag( { :action => "search", :method => "get" }, :class => "span4" ) do %>
...
<% end %>
without the /search, it correctly calls my controller method. can someone explain why? thanks
This will do what you mean:
If the first parameter of
form_tagis a hash as you have given, it is passed behind-the-scenes tourl_for, which inteprets:actionas the action part of a route for it to reverse-map.Since you (I guess) want to just pass a plain URL, just pass it as a string for the first arg.
More info here of course 🙂