View that allows HTML

34 views
Skip to first unread message

Adam

unread,
Mar 17, 2017, 3:37:07 AM3/17/17
to Ruby on Rails: Talk
Hi everyone,

I'm brand new to Ruby on Rails. I just went through the tutorial on the Ruby on Rails site which shows how to create a basic blog (http://guides.rubyonrails.org/getting_started.html). I'm trying to figure out how to adjust the view to allow HTML so that the posts have formatting. As it is now, the html tags are escaped. Is there a simple way to allow unescaped HTML into a view so that I can create a formatted post?

Thanks,

Adam

Nugi Nugraha

unread,
Mar 17, 2017, 4:00:25 AM3/17/17
to rubyonra...@googlegroups.com
On Fri, Mar 17, 2017 at 12:35 PM, Adam <adamt...@outlook.com> wrote:
Hi everyone,

I'm brand new to Ruby on Rails. I just went through the tutorial on the Ruby on Rails site which shows how to create a basic blog (http://guides.rubyonrails.org/getting_started.html). I'm trying to figure out how to adjust the view to allow HTML so that the posts have formatting. As it is now, the html tags are escaped. Is there a simple way to allow unescaped HTML into a view so that I can create a formatted post?

you can use html_safe on rails view.
ex : <%= @post.html_safe %>
 

Thanks,

Adam

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2fc060cd-9d9d-497e-94d8-6dfd5fd6ee7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mou Dareka no, tame janakutte
Jibun no Tame ni Warette Iru

( Aqua Timez - Alones )
Reply all
Reply to author
Forward
0 new messages