(rails) taking from DB and rendering into HTML -
I am creating a website for my Web Dev class, and I am stopping to render HTML. I want to be able to use a simpler form (I have too much for this controller, and I have tried to paste the content-type in my controller, but there is no progress.) Submit text and The idea is given as HTML, because this class requires a bunch of crap, which is excluded from the book and as a reference to HTML, maybe I Shri such as blog posts, I can serve them. (All on the same page, using the same layout. The only thing that changes is a content guide below the list of blog lists and data (Controller in question).
So, in a nutshell My question is: How do I get text from DB to present HTML tags instead of displaying as side text?
Thanks, and please tell me whether supplement information is necessary or not Cai Run
Edit: (Adding code is not really about last loft but, whatevs.) Also, it is not certain how the code snippet tool should work. I hope it Layers.
class ['content-type'] = 'text / html; charset = iffest [' content-type '] =' text-htmlfiler: header 8 & amp; nbsp;
#GET / DietPosts # GIT / DTaposts.xml def index @ dA Payposts = DAPPost.All @ Posts = Post.All
answer-to-dot format format .html # index.html.erb format.xml {render: xml = & gt; @dataposts} EndTermination
#GET / Dataposts / 1 #GET /dataposts/1.xml def Show @Deposts = Datapost.All @DitPost = Datapost .fund (param [: id]) @posts = post. All
do not answer_to. Format | Format.html # show.html.erb format.xml {Render: xml = & gt; @datapost} end
end of the end
This is the scene where to be provided. It is a partial that is called for the contents called by the homepage.
& lt; P & gt; & Lt; Small & gt; Post title & lt; / Small> & Lt;% = h @ datapost.title% & gt; & Lt; / P & gt; & Lt; Hour / & gt; & Lt; P & gt; & Lt;% = h @ datapost.body% & gt; & Lt; / P & gt; & Lt; Hour / & gt; & Lt; Hour / & gt; & Lt;% = link_to 'back', dataposts_path% & gt; I will go ahead and move forward which I have but prod.
(edit after ~ 5 minutes)
h The method you are calling here:
<% = h @ datapost.body% & gt; Also known as html_escape - is here. Remove it and present your HTML tags properly.
You should always display the code the user receives with the h method to prevent cross-site scripting attacks. But if it's code written by you (or whatever) then it should be fine.
Comments
Post a Comment