In my controller I have the action:
def booking_sheet_report
@groups = Group.all.order('priority DESC')
respond_to do |format|
format.html
format.csv
format.pdf
end
end
and in the view I want the user to be able to open (download) the format.pdf when clicking on a button_to element (I do have a booking_sheet_report.pdf.erb view). With a link_to (<%= link_to 'PDF', booking_sheet_report_path(format: :pdf) %>
) works fine.
I tried the followings without any success:
<%= button_to "PDF", {action: "booking_sheet_report", :form => { "data-type" => "pdf" }}, {class: 'btn-u', method: :get} %>
<%= button_to "PDF", {action: "booking_sheet_report(format: :pdf)", :form => { "data-type" => "pdf" }}, {class: 'btn-u', method: :get} %>
The second one gives an error: No route matches {:action=>"booking_sheet_report(format: :pdf)", :controller=>"reports", :form=>{"data-type"=>"pdf"}}
Any clue how is this possible or what I am doing wrong?
Edit: the one relevant route is get 'booking_sheet_report' => 'reports#booking_sheet_report'