1

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

What I ended up using is the following:

after_filter :save_if_necessary

and what I stored was

self.response.body

1 Comment

This is just what I needed. Similar circumstance, except I was saving dynamically rendered xml.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.