Rendering ERb markup from a database in Rails
If you need to render ERB markup that is stored in a database or a string, I discovered an easy way (though finding it was a little harder). I found a tip via a Robby On Rails blog post, which led me to the ticket he opened with a patch and a comment from the Rails team on a way to do this without patching Rails:
erb_template = grab_erb_from_database
content = render_to_string(:inline => erb_template)
Note: the render_to_string method is a protected controller method, so you will need to call this code in the action and store it in an instance variable for the view.
Technorati Tags: Ruby on Rails, ERb, rails rendering
James @ May 22, 2007