Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>(edited for Rails 3 as per the comment below)</p> <p>If I understand the question, you want the user to be able to enter HTML in their post content.</p> <p>First off if you're entering HTML tags manually but they show up as plain text (e.g. &lt;img src="..."/&gt; instead of the actual image) you have to go into your view and add "raw" before the post body.</p> <pre><code>&lt;%= @post.body %&gt; </code></pre> <p>should be </p> <pre><code>&lt;%= raw @post.body %&gt; </code></pre> <p>Rails 3 by default protects you against users that try to insert HTML into unwanted parts of your site. For example without it if I leave a comment on your post, I could insert some malicious &lt;javascript&gt; tags. But if you're the only one making posts, that's obviously not an issue, so it's safe to display the "raw" html content.</p> <p>As for the HTML itself, you could conceivably make your text field interpret rails code (like the link_to or image_tag helpers) but that's bat country, unless you're really, really sure what you're doing I wouldn't go there. (And even if you do know I wouldn't recommend it.)</p> <p>You can look into a simpler markup language like <a href="http://redcloth.org/" rel="nofollow">RedCloth</a>, very easy to implement but also somewhat limited, or you can go all-out WYSIWYG like <a href="http://ckeditor.com/" rel="nofollow">CKEditor</a> or <a href="http://www.wymeditor.org/" rel="nofollow">WYMEditor</a></p> <p>StackOverflow uses <a href="http://wmd-editor.com/" rel="nofollow">WMD-editor</a>, a combination of a simple markup engine and a WYSIWYG text field.</p> <p>I usually go with CKE because it has a very complete feature set and it's easy to use for people who are used to MSWord-like editors.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload