jeudi 27 avril 2023

Respond_to format in Rails 5

I am having problems getting respond_to format working in Rails 5 app in controller, is just for downloading a csv list of users, as below: def customers_graylist_export @graylisted_users = Customer.where(status_trust: 'graylist') respond_to do |format| format.csv do response.headers['Content-Type'] = 'text/csv' response.headers['Content-Disposition'] = "attachment; filename=ListaCinza.csv" end end end

And getting unknown format error on line "respond_to do |format|" the mime type is registered in mime_types initializer, and this should be straightforward, but Rails 5 is a little quirky!

Any suggestions welcome?

Many Thanks

Aucun commentaire:

Enregistrer un commentaire