I guess I’m looking to add some CMS type functionality to my web app. In it’s simplest form I will create some content, store it, and then call it in a view.
I have an “article” model with art_name and art_content string fields.
in some “Pages” controller I store a variable of the particular article I would like displayed on a page as:
@article_wanted = article.find(5).art_content
In a view I call this variable <%= @article_wanted %>and the string in the art_content of the appropriate model (ID 5 in this example) is output. This is great… however I would like to store html as my art_content string so I can add h1 tags, css classes,…etc. By using my current methodology the art_content string is displayed on the browser as it was saved (tags visible) <h1>article content header</h1>. I think that because I’ve defined the model field as a string the tags are converted:
<h1>art content header</h1>
How do I get around this?
is there a better way to publish articles to a page that is better than my current method? where I’m calling a controller variable, from an html content field of some model, in a view?
Thanks!
This doesn’t really address the question of wanting full CMS functionality (google “rails cms”), but did you try
<%= raw @article_wanted %>?