Rails存储表单数据

时间:2016-06-13 09:15:57

标签: ruby-on-rails ruby forms

我正在尝试从搜索表单中获取查询,将其存储在变量中,并将其作为查询传递给twitter api,但我担心我对如何存储输入感到困惑。我在layouts / application.html.erb

中设置了表单
  <%= form_tag(:method => "get", id: "search-form") do %>
    <%= text_field_tag :search, params[:search], placeholder: "Search" %>
    <%= submit_tag "Search", :name => nil %>
  <% end %>

但实际上,我不知道如何保存输入,当我点击搜索按钮时,出现路由错误“没有路由匹配”[POST] / pages / home“

1 个答案:

答案 0 :(得分:0)

我觉得这样的事情

<%= form_tag your_path_here,:method => "get", id: "search-form" do %>
<%= text_field_tag :search, params[:search], placeholder: "Search" %>
<%= submit_tag "Search", :name => nil %>
<% end %>