no route matches even after adding route to routes.rb
This is the code in the view.
<% form_tag({:controller => 'users',
:action => 'test'}) do %>
<%= text_field_tag(:search_options, params[:search_options])%>
<%= submit_tag("Display text!")%>
<% end -%>
I have a f开发者_运维问答ile test.html.erb and have also added get "users/test" to routes.rb still i'm getting Error: No route matches "/users/test"
The form_tag
method creates a form to be send using HTTP POST by default. You state that the route you define in your routes.rb
is a GET. So you have two options to fix this problem:
- Change your route to
POST "users/test"
- Change your
form_tag
call to:form_tag({:controller => 'users', :action => 'test'}, :method => :get)
精彩评论