Forum: Ruby on Rails Write Static File for View Output?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
78afdba6236b562b3c0f582d69cd161a?d=identicon&s=25 Sav (Guest)
on 2009-04-25 18:59
(Received via mailing list)
Is it possible to save a view's output into a static file rather than
dynamically generate it each request?...

I've got a working controller method and view to select my db records
and format them into a custom XML output, but I'd like to save the
view output into "/public/data/{params[:id]}.xml"
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-25 19:54
(Received via mailing list)
On Apr 25, 5:58 pm, Sav <savar...@gmail.com> wrote:
> Is it possible to save a view's output into a static file rather than
> dynamically generate it each request?...
>
> I've got a working controller method and view to select my db records
> and format them into a custom XML output, but I'd like to save the
> view output into "/public/data/{params[:id]}.xml"

Sounds to me like you should read up on action controller's caching
support.

Fred
782b01570270ab10543bc25a258d7ea8?d=identicon&s=25 Dmitry Sokurenko (Guest)
on 2009-04-26 01:11
(Received via mailing list)
Just use page caching:

DataController
  caches_page :show

  def show
    # generate the XML
  end
end

Now there will be a lot of files like:
/public/data/1.xml
/public/data/2.xml
/public/data/3.xml
...

Dmitry
This topic is locked and can not be replied to.