Frage

I'm trying to implement redactor as a WYSIWYG editor with ruby on rails. Everything seems to be working fine except that when I edit text in the editor the html tags show up. This happens even when I use the html button on the toolbar.

So on the webpage the text appears something like this:

<p>Edited text here</p>

I haven't included any code because I'm not really sure where to begin looking with this so any help at all will be appreciated :)

War es hilfreich?

Lösung

when using a text editor you have to tell your rails app that the area is html safe. This is (by default) not the case as people could attack your site by using a text box you have put into your app.

by declaring an area as html safe you should be able to use the html tags as you like. be aware of the security risk for using this.

e.g.

<div class="description">
   <%= @foo.foo_desc.html_safe%>
</div>

Hope this clears it up for you.

Andere Tipps

in your view try using raw before the text you are trying to show. For example

<%= raw @post.body %>

this will work out with the html tags and show the processed text only without the tags.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top