Respond_to, mime types and excel

Hello All,

I’m trying to figure out how respond_to actually works, especially with
the increased focus on REST.

After I set a MIME type for Excel

Mime::Type.register “application/vnd.ms-excel”, :xls

In my index action’s respond_to block

I have format.xls {
@parts = Part.find(:all)
headers[‘Content-Type’] = “application/vnd.ms-excel”
headers[‘Content-Disposition’] = “attachment;
filename=“parts-inventory-#{Time.now.strftime(”%m-%d-%Y”)}.xls""
headers[‘Cache-Control’] = ‘’
render( :action=>“inbound.rxml”, :layout => false)
}

but how do i actually trigger the action to return the spreadsheet
instead of the HTML page?

when i try index.xls it tries to render the show function.

If anyone can explain this that would be much appreciated.

Binh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs