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 8072727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:06:56+00:00 2026-06-05T14:06:56+00:00

I have a Portfolio model that contains a comments field of type text, whose

  • 0

I have a Portfolio model that contains a comments field of type text, whose values are a set of paragraphs delimited by some combo of cr and nl characters. The objective is to extract the paragraphs into an array, wrap them in <p> tags, and rejoin them for output to the browser; so the focus in the code below is lines 6-8.

The problem I’m having is that the < and > characters are getting rendered as HTML entities &lt; and &gt;.

I’m new to Ruby and Rails, so my guess is that the reason this isn’t working as intended is because I’m probably taking an incorrect approach–and I’d like to know how an experienced Ruby coder would address this sort of situation. How do you insert HTML tags into content before you send it to a view? Or is that always a violation of the MVC model–in which case, what’s a correct way to solve this sort of problem?

Here’s the code:

1.   module ApplicationHelper
2.   
3.     def portfolio_featured
4.       @portfolios = Portfolio.all
5.       @portfolios.each do |p|
6.         paras = p.comments.split(/\r?\n\r?\n/)
7.         paras.collect! { |p| "<p>" + p + "</p>" }
8.         p.comments = paras.join
9.       end
10.    end
11.
12.  end
  • 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-06-05T14:06:57+00:00Added an answer on June 5, 2026 at 2:06 pm

    take a look at simple_format TextHelper.

    It is probably what you are looking for.

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

Sidebar

Related Questions

I have the following model: class Entry include Mongoid::Document field :title, type: String field
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I just designed a portfolio website. I have a whole array of images that
I'm creating a Django powered website that will have numerous applications (Blog, Shop, Portfolio,
I am building a portfolio website using CakePHP and have named my model 'Portfolio'
I have a rewirte rule that rewrites my portfolio urls from portfolio.php?cat=cat-name&project=project-slug to /portfolio/cat/slug/
Hey guys, I have a custom post type, portfolio, and I want to store
I have a portfolio web app that is run on Sinatra using pjax .
I like to have a portfolio that is dynamic and simple to update. In
I have a one-page portfolio style website that scrolls with JQuery, and I cannot

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.