2014-04-05 57 views

回答

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

+0

謝謝@尼米爾,我可以看到第一個建議沒有搞亂造型。但是,如何將搜索文本放入查詢中?當我提交它時,它只會在2014-04-05 16:33:13 + 0200'上進入'127.0.0.1開始POST「/ rotas」。 – JohnSmith1976

+0

'/ rotas'就是一個例子,你應該將它替換爲你想要接收搜索查詢的路徑 – Nimir

+0

是的,我明白了,但是假設我有'/ rotas'路徑,我仍然需要我的查詢這些參數。像例如'/ ROTAS?查詢= mysearch'。 – JohnSmith1976