Ruby on rails 如何在url中传递多个参数?

Ruby on rails 如何在url中传递多个参数?,ruby-on-rails,Ruby On Rails,我正在尝试为一个项目创建一个自定义路径,我发送ID和一个月和一年来显示一些数据,这些参数是用表单_发送的,并创建了一个糟糕的url: http://localhost:3000/havings_discount_record/employee?utf8=%E2%9C%93&having%5Bemployee_id%5D=1&having%5Bhavings_month%5D=7&having%5Bhavings_year%5D=2019&commit=Busqueda 我试图从以下位置更改路线:

我正在尝试为一个项目创建一个自定义路径,我发送ID和一个月和一年来显示一些数据,这些参数是用表单_发送的,并创建了一个糟糕的url:
http://localhost:3000/havings_discount_record/employee?utf8=%E2%9C%93&having%5Bemployee_id%5D=1&having%5Bhavings_month%5D=7&having%5Bhavings_year%5D=2019&commit=Busqueda

我试图从以下位置更改路线:

get 'havings_discount_record/employee', to: 'havings_discount_record#record_per_employee', as: 'record_per_employee'
致:
获取'havings\u折扣记录/employee/:employee\u id/:havings\u month/:havings\u year',至:'havings\u折扣记录#记录每位员工',如:'record\u per\u employee'
但我记得不是这样工作的,数据是在按下提交按钮后发送的

 <%= form_for @havings, url: record_per_employee_path, method: :get  do |data| %>
    <%= data.text_field :employee_id %>
    <%= data.text_field :havings_month %>
    <%= data.text_field :havings_year %>
    <%= data.submit "Busqueda"%>
  <% end %>

我希望url尽可能简单,只显示以下内容:


http://localhost:3000/havings_discount_record/employee/1/7/2019

最后我尝试了另一件事,我在我的控制器中创建了一个方法(这是一个简化的示例):

def search
  @employee_id = params[:legal_vacation][:employee_id]
  redirect_to employee_pool_path(@employee_id)
end
我创建了一个路由并将我的表单数据发送到这个方法,通过这种方式,您可以在应用程序中使用一个:id,并避免使用庞大的查询字符串。 我希望这能帮助你在未来或过去,或任何事情。如果你有别的办法,请告诉我