Ok. I know this is very basic. I want to have some basic tags around text content in the database to be processed in the view's rendering.
Basically, I have a model named Page.
rails g model Page name:string content:text
I want whatever is in the content field to be shown in the view but, if there is HTML in the content field, I want it to be processed not just shown.
For example, in my Page#show view, I may have:
<%= @page.content %>
Which outputs:
< p >This is my first < b >paragraph< /b >.< /p >
When I want it to output:
This is my first paragraph.
Again, please be gentle. I know this is probably pretty basic but I am having a hard time searching for how to do this. :)
You can use the raw helper method.
<%=raw @page.content %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With