开发者

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

开发者 https://www.devze.com 2022-12-21 15:18 出处:网络
Is there a way to capture the output of my view file after it 开发者_StackOverflow社区is rendered?

Is there a way to capture the output of my view file after it 开发者_StackOverflow社区is rendered?

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


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.


What I ended up using is the following:

after_filter :save_if_necessary

and what I stored was

self.response.body
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号