Forum: Ruby on Rails save view to file

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Paul (Guest)
on 2006-05-30 00:24

I am trying to figure out a way to save the view of an action to a file.

I have an action call makehtml.  It gets data from a database and create
a view that display the result in a browser.  I would like to save that
result view page to a file in public/htmls for example.

Does anyone know how I can do this?

Thanks for all your help in advance.
Jonathan V. (Guest)
on 2006-05-30 07:37
(Received via mailing list)
You can probably use an after_filter:

class MyController < ApplicationController
  after_filter :save_html, :only => :makehtml

  def makehtml
    # Do normal stuff

  def save_html'/tmp/makehtml.html', 'w') do |f|
      f.write response.body

That should do it (untested).

Paul (Guest)
on 2006-05-31 06:33

Thank you very much!  That worked very well.

This topic is locked and can not be replied to.