Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3451376
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:08:18+00:00 2026-05-18T09:08:18+00:00

Rails Newb here asking his first question…. I’m building a personal blog-style website that

  • 0

Rails Newb here asking his first question….

I’m building a personal blog-style website that uses a generic “Post” scaffold to add content to the site. The fields are title:string, body:text, and :tag_list respectively. Acts-as-taggable sorts the posts and puts them on the correct page.

When I create a new post and enter text into the :body, I can’t get it to recognize anything other than pure text. I’m trying to get it to accept in-line html tags, rails methods (i.e. link_to, image_tag) in the text itself. As I’m typing this I realize what I’m looking for is the basic functionality of most blogging text editors. Is there any easy way to do this?

Here is my posts model:

class Post < ActiveRecord::Base
  has_many :tags
  acts_as_taggable_on :tags
  attr_accessible :tag_list, :tags, :title, :body, :post, :comments
  validates :title, :presence => true, :length   => { :maximum => 30 }
  validates :body, :presence => true
  default_scope :order => 'posts.created_at DESC'
  named_scope :by_join_date, :order => "created_at DESC"

Here is my posts helper:

module PostsHelper
    include ActsAsTaggableOn::TagsHelper
    include TagsHelper

The Posts Controller and Post Views are all basicallu unchanged from the scaffold code.

Thanks in advance for all your help!

~Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:08:19+00:00Added an answer on May 18, 2026 at 9:08 am

    (edited for Rails 3 as per the comment below)

    If I understand the question, you want the user to be able to enter HTML in their post content.

    First off if you’re entering HTML tags manually but they show up as plain text (e.g. <img src=”…”/> instead of the actual image) you have to go into your view and add “raw” before the post body.

    <%= @post.body %>
    

    should be

    <%= raw @post.body %>
    

    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 <javascript> 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.

    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.)

    You can look into a simpler markup language like RedCloth, very easy to implement but also somewhat limited, or you can go all-out WYSIWYG like CKEditor or WYMEditor

    StackOverflow uses WMD-editor, a combination of a simple markup engine and a WYSIWYG text field.

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first time poster - semi-newb to Rails. Here is my question. Suppose you have
Newb RoR developer here, standing at the finish line of my first paying Rails
Rails newbie question that I can't seem to figure out. At some point I
Rails newb question: Say I'm currently viewing the show.html for one of my classes(
I'm a newb with Rails and am trying to get out my first Rails
Warning:Total Rails Newb (TRN). This should be a pretty basic question so I'm hoping
I'm a newb to RoR. I'm using the book Agile Web Development with Rails
Rails make It possible to map resources that are logically children of other resources
Rails has a nice idiom that makes it easy for you to have a
Rails question. The default behavior for error validation is to fieldWithError-styled div around the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.