# Rendering View output to a file

**URL:** <https://www.ruby-forum.com/t/rendering-view-output-to-a-file/195954>\
**Category:** Rails\
**Created:** [October 3, 2010, 10:37pm UTC](https://www.ruby-forum.com/t/rendering-view-output-to-a-file/195954 "2010-10-03T22:37:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [October 3, 2010, 10:37pm UTC](https://www.ruby-forum.com/t/rendering-view-output-to-a-file/195954/1 "2010-10-03T22:37:01Z")

</div>

I want to generate a set of static HTML pages for uploading to a site.  
Is there a simple way to get a Controller/View to render to a file or  
directory, suitable for uploading?

I know I could fire up the server, render the page and save it from a  
browser, but that would be tedious after the first dozen or so pages…

TIA.

- ff

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [October 4, 2010, 4:29pm UTC](https://www.ruby-forum.com/t/rendering-view-output-to-a-file/195954/2 "2010-10-04T16:29:03Z")

</div>

On Sun, Oct 3, 2010 at 1:37 PM, Fearless F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I want to generate a set of static HTML pages for uploading to a site.

> I know I could fire up the server, render the page and save it from a  
> browser, but that would be tedious after the first dozen or so pages…

Or just use `wget` in “spider” mode to crawl and retrieve the whole set  
with one command 🙂

## FWIW,

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [October 3, 2010, 11:59pm UTC](https://www.ruby-forum.com/t/rendering-view-output-to-a-file/195954/3 "2010-10-03T23:59:28Z")

</div>

You could use page caching. That would output files to tmp/cache

Luke

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [October 4, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/rendering-view-output-to-a-file/195954/4 "2010-10-04T18:22:28Z")

</div>

Hassan S. wrote:

> On Sun, Oct 3, 2010 at 1:37 PM, Fearless F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > I want to generate a set of static HTML pages for uploading to a site.

You might want to look into how StaticMatic does this (though I believe  
it’s build on Merb, not Rails). If StaticMatic itself is not suitable  
for your purposes, its build script may have useful ideas.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
