def exportxml
if params[:item_ids]
@items = Item.find(params[:item_ids])
respond_to do |format|
format.xml {
send_data @items.to_xml, :filename => "items.xml"
}
end
end
end
On Fri, Oct 17, 2008 at 6:59 AM, Nik <[EMAIL PROTECTED]> wrote:
>
> Thanks Simon,
>
> Where should I put this code? I have in my controller:
>
> #Controller
>
> def exportxml
> if params[:item_ids]
> @items = Item.find(params[:item_ids])
>
> respond_to do |format|
> format.xml {render :layout=>false}
> end
> end
> end
>
> Cheers!
> Nik
> On Oct 13, 5:10 pm, "Simon Macneall" <[EMAIL PROTECTED]> wrote:
>> HiNik,
>>
>> This is what we have and it seems to work in all the browsers
>>
>> response.body = xml.to_s
>> response.content_type = "application/x-generated-xml-backup";
>> filename = "Filename.xml"
>> response.headers['Content-disposition'] = "Attachment;
>> filename=\"#{filename}\""
>> render :text => xml.to_s
>>
>> Cheers
>> Simon
>>
>> On Tue, 14 Oct 2008 07:54:52 +0800,Nik<[EMAIL PROTECTED]> wrote:
>>
>> > Hello all,
>>
>> > I am trying to export some xml files on the web app as a download, but
>> > Firefox/chrome/ie/safari all just display the xml content on
>> > themselves. How can I have the download prompt? Like I am downloading
>> > a .exe file?
>>
>> > Thank You
> >
>
--
Satchel Paige - "Don't look back. Something might be gaining on you."
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---