I\'m having problems with Rails method: send_data
Here\'s my action:
def export
send_data(current_user.contacts.to_csv,
type: \'te
I figured it out.
It was turbolinks that was messing it all up. I added data-no-turbolink to the export link and now it works as expected.
The answers here, are for turbolinks classic. There is a newer notation on newer versions of turbolinks:
<a href="/" data-turbolinks="false">Disabled</a>
https://github.com/turbolinks/turbolinks#disabling-turbolinks-on-specific-links
send_data has an option hash, so type, disposition and filename need to be set in a hash:
def export
send_data(current_user.contacts.to_csv,
type: 'text/csv', disposition: 'attachment', filename: 'contacts.csv')
end