Write Static File for View Output?


#1

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”


#2

On Apr 25, 5:58 pm, Sav removed_email_address@domain.invalid 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


#3

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