我有一个我从this tutorial创建的搜索表单。但是如何让它为指定的控制器和指定的操作执行实际查询?
%form
%input{:placeholder => "Find something...", :required => "", :type => "text"}
%button{:type => "submit"} Search
答案 0 :(得分:0)
您需要为表单添加目标:
%form{ :action => "/rotas", :method => "get" }
%input{:placeholder => "Find something...", :required => "", :type => "text"}
%button{:type => "submit"} Search
或者您可以使用form_tag helper,例如:
=form_tag(controller: :posts , action: :index, method: :get) do |f|
= f.text_field :query, nil, :placeholder => "Find something..."
= f.submit "Search"
并记得留意indentations!