I have a controller method written along these lines:
begin
system("/script/that/generates/output > text_file")
var += IO.readlines("text_file")
send_data var, :filename => "attachment.txt", :disposition =>
'attachment', :type => 'text/plain'
rescue
flash[:error] = "Error message here"
redirect_to :action => 'error_page'
end
What this is supposed to do is send the contents of the text file plus
some other data directly to the user. The problem is, of course, that
the system call will not run from a Rails controller as this is
apparently considered very naughty. I could instead use backgroundrb to
generate the file (the same system call is fine as part of a
backgroundrb job) and then e-mail it to users but I would rather send it
immediately as the attachment is virtually instantaneous. Is
backgroundrb really the only way to do that? It seems a bit much for
such a small task.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---