engage2245
engage2245

Reputation: 93

Capture HTML output from the view in RAILS and save to DB

Is there a way to capture the output of my view file after it is rendered?

I basically want to save the full HTML output into a database after the page renders.

Upvotes: 1

Views: 2051

Answers (2)

engage2245
engage2245

Reputation: 93

What I ended up using is the following:

after_filter :save_if_necessary

and what I stored was

self.response.body

Upvotes: 3

TheClair
TheClair

Reputation: 721

You could use render_to_string, then stick it in the db and send the string containing the rendering to the browser. See RoR render_to_string doc.

Upvotes: 3

Related Questions