# RE: Form -\> File save tutorial

**URL:** <https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035>\
**Category:** Rails\
**Created:** [February 13, 2006, 4:08pm UTC](https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035 "2006-02-13T16:08:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HoganS\_Brian\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@HoganS\_Brian\_P](https://www.ruby-forum.com/u/HoganS_Brian_P)\
**Post date:** [February 13, 2006, 4:08pm UTC](https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035/1 "2006-02-13T16:08:13Z")

</div>

Pretty simple thing actually…

Take the data from the forms, store it somewhere (db maybe or session)  
and then make an xml view (.rxml) that displays it back to the users.  
you can’t easily save things to a user’s hard drive, but you can make a  
link for them that they can right-click and save. (the link would  
obviously point to the controller and action that would render the rxml  
template.)

(Just be sure to do render :layout=\>false when you render the rxml  
template.

Hope that nudges you along a bit.

---

<div class="post-metadata">

**Author:** ![HoganS\_Brian\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@HoganS\_Brian\_P](https://www.ruby-forum.com/u/HoganS_Brian_P)\
**Post date:** [February 13, 2006, 4:54pm UTC](https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035/2 "2006-02-13T16:54:53Z")

</div>

MessageHi Brian,

Thanks for the reply. Some of my target users will not have the web  
experience to understand the right-click thing. I’m wondering if there  
isn’t a way to present them with a “Save” button that would somehow then  
send the right-click message. Any thoughts?

Also, what about Mac users? I haven’t had a Mac for years now, but  
don’t they still use a one-button mouse? How do they do a “Save target  
as…”?

Thanks,  
Bill  
----- Original Message -----  
From: Hogan, Brian P.  
To: removed\_email\_address@domain.invalid  
Sent: Monday, February 13, 2006 9:07 AM  
Subject: RE: [Rails] Form → File save tutorial

Pretty simple thing actually…

Take the data from the forms, store it somewhere (db maybe or session)  
and then make an xml view (.rxml) that displays it back to the users.  
you can’t easily save things to a user’s hard drive, but you can make a  
link for them that they can right-click and save. (the link would  
obviously point to the controller and action that would render the rxml  
template.)

(Just be sure to do render :layout=\>false when you render the rxml  
template.

Hope that nudges you along a bit.

-----Original Message-----  
From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Bill W.  
Sent: Monday, February 13, 2006 7:28 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Rails] Form → File save tutorial

I want to develop a web application that allows a user to input data  
into a set of forms and then save that data in an XML file format to  
their hard drive. Can anybody point me to a Ruby\Rails tutorial that  
would help?

Thanks,  
Bill

* * *

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![HoganS\_Brian\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@HoganS\_Brian\_P](https://www.ruby-forum.com/u/HoganS_Brian_P)\
**Post date:** [February 13, 2006, 4:59pm UTC](https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035/3 "2006-02-13T16:59:15Z")

</div>

How about have a link/button that redirects the user (or pops up a new  
window) to the view that creates the XML? Then, they could just do a  
File -\> Save?

---

<div class="post-metadata">

**Author:** ![HoganS\_Brian\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@HoganS\_Brian\_P](https://www.ruby-forum.com/u/HoganS_Brian_P)\
**Post date:** [February 13, 2006, 5:59pm UTC](https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035/4 "2006-02-13T17:59:31Z")

</div>

On 13 Feb 2006, at 16:13, Thibaut BarrÃ¨re wrote:

> as a newcomer to mac, I’ve been equally wondering ! (just like…  
> how to I get this pipe | character on my azerty keyboard. is it  
> also ctrl+alt+L on qwerty macs?)

No, it’s Shift-\ to get | on a UK mac keyboard.

And yes, holding down ctrl whilst clicking will _always_ give you the  
equivalent of a “right-click”…

Is it just me or this list getting weird right now?

---

<div class="post-metadata">

**Author:** ![HoganS\_Brian\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@HoganS\_Brian\_P](https://www.ruby-forum.com/u/HoganS_Brian_P)\
**Post date:** [February 13, 2006, 5:15pm UTC](https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035/5 "2006-02-13T17:15:31Z")

</div>

> Also, what about Mac users? I haven’t had a Mac for years now, but don’t  
> they still use a one-button mouse? How do they do a “Save  
> target as…”?

as a newcomer to mac, I’ve been equally wondering ! (just like… how to  
I  
get this pipe | character on my azerty keyboard. is it also ctrl+alt+L  
on  
qwerty macs?)

In Safari you just have to press ctrl then click to get alternative  
choices  
such as download to.

Thibaut

---

<div class="post-metadata">

**Author:** ![HoganS\_Brian\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@HoganS\_Brian\_P](https://www.ruby-forum.com/u/HoganS_Brian_P)\
**Post date:** [February 13, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/re-form-file-save-tutorial/67035/6 "2006-02-13T18:24:00Z")

</div>

try something along the lines (untested):

In controller:

def save\_to\_xml  
xml\_data = GENERATE\_YOUR\_XML\_DATA\_HERE  
send\_data xml\_data, :filename =\> “SOME\_NAME\_HERE.pdf”,  
:type =\> “application/pdf”  
end

In your view put a Link somewhere with the option target=“\_new”

That should work BUT as said above it wasn’t tested.

have fun

Jorge S.

On 2/13/06, Paul R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is it just me or this list getting weird right now?
> 
> –  
> Paul R.

–
