Take the 2-minute tour ×

So in my DB I want stored a ruby/HTML statement in the Database Table such as - p This site is owned from 2000 - #{Time.now.year} by Acme Widget Co. /p

Or let's say that I want people to be able to include in other code snippits - e.g. A client wants to run in a show view in the middle of a paragraph some magical partial such as #{render 'my_magical_code'}

On the view I have this being rendered as <%= raw(@page.content) %>

But its like a double rendering and rails will just put on the page #{render 'my_magical_code'} or #{Time.now.year}

So can / how do I solve this?


share|improve this question
add comment

1 Answer

There are work arounds but I think the most proper way to solve your problem is to store your information in a better way. Add a migration to your model with a year_founded and company rows. You can then call these in your views rather than storing the HTML. Eg.

This site is owned from <%= @object.year_founded %> to <%= Time.now.year %> by <%= @object.company %>

share|improve this answer
Hey Tom Thanks for the answer. and Sure the examples are quite simple, but the real life app is much more complex than what I gave. So can you or someone point me to a few work arounds? –  tspore Oct 28 '12 at 22:49
add comment

Your Answer


