# How to download a dynamically generated file

**URL:** <https://www.ruby-forum.com/t/how-to-download-a-dynamically-generated-file/157170>\
**Category:** Rails\
**Created:** [January 8, 2009, 3:28am UTC](https://www.ruby-forum.com/t/how-to-download-a-dynamically-generated-file/157170 "2009-01-08T03:28:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 8, 2009, 3:28am UTC](https://www.ruby-forum.com/t/how-to-download-a-dynamically-generated-file/157170/1 "2009-01-08T03:28:37Z")

</div>

I need to provide users a link to download an user\_guide.txt file.

Currently the user\_guide.html.erb looks like this.

Dear \<%=@user.name %\>,

Please visit \<%=@unlocking\_webiste %\> site.

…  
…

the point is that the file has some variables which needs to be  
replaced then user should be able to download these files and use  
them.

I can find ways to download a static file but in this case how should  
I code such that users are able to download the customized files.

Thanks

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 8, 2009, 10:22am UTC](https://www.ruby-forum.com/t/how-to-download-a-dynamically-generated-file/157170/2 "2009-01-08T10:22:11Z")

</div>

Use render\_to\_string(options = nil, &block) and use the send\_data  
API.
