为搜索表单添加参数以保持持久性

时间:2017-09-04 08:03:40

标签: ruby-on-rails-4 will-paginate

表单定位到结果页面:

<%= form_tag results_interventos_path do %>
      From: <%= date_select :intervento, :from, { order: [:day, :month, :year], default: Date.today-31, start_year: Time.now.year-1, end_year: Time.now.year, datetime_separator: "&nbsp;" } %>
      To: <%= date_select :intervento, :to, { order: [:day, :month, :year], default: Date.today-30, start_year: Time.now.year-1, end_year: Time.now.year, datetime_separator: "&nbsp;" } %>
      <%= collection_select(:intervento, :invoicestate_id,  Invoicestate.all, :id, :nome, prompt: "tutti") %>

结果将路由到目前定义为:

的分页(带will_paginate)页面
post :results

目标:维护网址中的搜索参数,以便可以使用:back符号

定义的链接返回从结果页面获取的任何操作

1 个答案:

答案 0 :(得分:0)

通过正确的路由,解决了这个问题:

get  :results

表格也应该指出正确的方法

<%= form_tag results_interventos_path, method: :get do %>

否则会尝试发帖。