rails won't send_data as file

后端 未结 3 1737
一整个雨季
一整个雨季 2020-12-06 16:57

I\'m having problems with Rails method: send_data

Here\'s my action:

def export
  send_data(current_user.contacts.to_csv,
    type: \'te         


        
3条回答
  •  春和景丽
    2020-12-06 17:47

    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
    

提交回复
热议问题