Reputation: 19324
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?
Upvotes: 25
Views: 16338
Reputation: 4680
Works for me
<%= link_to('Export to Excel', reports_affirmative_action_path(:format => :xls)) %>
Use :xls instead of :xlsx
Upvotes: -3
Reputation: 1132
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
.
Upvotes: 51