I am generating a xls using 'to_xls' gem. So I have like:
my_xls = User.all.to_xls
Now I want to send it using ActionMailer, I tried like that:
attachments[my_xls.original_filename] = {
:content=>my_xls.read,
:mime_type=>my_xls.content_type
}
But for my surprise, my_xls is not a file but a String. I guess I could solve that by opening a new file and writing the string to it, but I'm using Heroku and it doesn't like writing to file (Permission denied). The best solution would be generate a file-like stream data (like getting a file from a HTML form) and send it.
I need something like rails send_data controller method, that send a stream of data to the view without generating a new file.
So, how do I do that?