# HTML from view into controller

**URL:** <https://www.ruby-forum.com/t/html-from-view-into-controller/151689>\
**Category:** Rails\
**Created:** [October 24, 2008, 12:52pm UTC](https://www.ruby-forum.com/t/html-from-view-into-controller/151689 "2008-10-24T12:52:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorter9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@gorter9](https://www.ruby-forum.com/u/gorter9)\
**Post date:** [October 24, 2008, 12:52pm UTC](https://www.ruby-forum.com/t/html-from-view-into-controller/151689/1 "2008-10-24T12:52:28Z")

</div>

How can i get the html code create by a view into the controller

I need to save the html created into a view into a file  
something like

File.open( ‘index.html’, ‘w’ ){|file| file.write (The\_view)}

---

<div class="post-metadata">

**Author:** ![gorter9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@gorter9](https://www.ruby-forum.com/u/gorter9)\
**Post date:** [October 24, 2008, 1:03pm UTC](https://www.ruby-forum.com/t/html-from-view-into-controller/151689/2 "2008-10-24T13:03:45Z")

</div>

You can try the render\_to\_string method:  
[http://api.rubyonrails.com/classes/ActionController/Base.html#M000475](http://api.rubyonrails.com/classes/ActionController/Base.html#M000475)

Regards

GA Gorter escribiÃ³:
