If I hit this url: http://localhost:3000/reports/action.xlsx it shows a generated xlsx file.
If I have a link_to like this:
<%= link_to 'Export to Excel', reports_affirmative_action_path, :format => :xlsx %>
It generates a link to this page:
http://localhost:3000/reports/action
Why does my link_to with :format => :xlsx not link to the correct path?
Your link_to and path are slightly off. You want
<%= link_to('Export to Excel', reports_affirmative_action_path(format: :xlsx)) %>
Where the format is an argument to the path helper, not link_to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With