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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:35:42+00:00 2026-06-04T13:35:42+00:00

I am using Rails 3.2.x and I have following code in view. <%= order.address.address_array.join(‘<br

  • 0

I am using Rails 3.2.x and I have following code in view.

<%= order.address.address_array.join('<br />').html_safe %>

address is an array of address1, address2, city name, state name, country name and zip code – standard stuff.

Since I am marking the content as html_safe if user enters <script>something</script. in city name then that javascript code will be executed.

What is a clean way to show address with line break without exposing security issue.

  • 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-04T13:35:43+00:00Added an answer on June 4, 2026 at 1:35 pm

    You have to call html_safe on each lines of your address array before joining. It should looks like that (not tested):

    <%= order.address.address_array.map(&:html_escape).join('<br />') %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render
In a Rails application using prototype, I have the following (simplified) code in my
please help with the following:(using rails 3 and jquery) In my view i have:
Using Ruby 1.9.2, Rails 3.1. I have the following code: # review.rb def calculate_rating(reviewable)
I am using Rails 3.0.9 with the ckedit gem. I have the following code
I am using Ruby on Rails v3.0.9 and I have the following code in
I am using Rails 3.2. I have following models: Blog Comment User class Blog
I'm using: Rails 3.0.9 Activerecord-sqlserver-adapter 3.0.15 TinyTds MSSQL 2005 I have following table: CREATE
I have recently created a new rails 3 application, using the code that I
I have a rails backend and am testing the following jquery code against it:

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.