rails4,如何传递所有参数

时间:2014-09-22 02:26:17

标签: ruby-on-rails

我将数据导出到XLS

def export_report
  require 'csv'
  @call_requests = CallRequest.reorder("created_at desc")
  @call_requests = @call_requests.where(:device=> params[:device]) if params[:device].present?
  @call_requests = @call_requests.where(:status => params[:status]) if params[:status].present?
  .....
end

我将传递许多参数(9~10的参数)

<%= link_to export_report_admin_call_requests_path(device: params[:device], status: parmas[:status], ......format: "xls") do %>
    Export Report
<% end %>

传递所有参数

是如此之久

可以传递所有参数吗?

1 个答案:

答案 0 :(得分:0)

您只需将format数据合并到params

<%= link_to export_report_admin_call_requests_path(params.merge(format: 'xls')) do %>
    Export Report
<% end %>