开发者

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:

  1. Change your route to POST "users/test"
  2. Change your form_tag call to: form_tag({:controller => 'users', :action => 'test'}, :method => :get)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜