On 24 Jun 2010, at 17:19, Fritz Trapper wrote:

It's really a member function of

class data < ActiveRecord::Base
 def to_excel_2003
   debugger
 end
end

and gets called from format.xls { render :xls => @data.to_excel_2003 }

My problem now is to find a trick to redirect back to show after
downloading the file.

As a result, the client should ge a download dialog to store the file.

Instead of render :xls, use send_data with the correct options to serve the file with disposition attachment (see the docs), this will bring up the dialog box right away and you never have to redirect to show, since a file download doesn't do a page refresh.

You'll need to implement the to_excel_2003 method to return a string at the end that will constitute the contents of the file. It's up to you to figure out which method of actually generating the string fits your project best and implement it.

Best regards

Peter De Berdt

--
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to