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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:36:29+00:00 2026-05-20T13:36:29+00:00

I want to be able to pass multiple messages to the flash hash, inside

  • 0

I want to be able to pass multiple messages to the flash hash, inside of my controller, and have them display nicely together, e.g., in a bulleted list. The way I’ve devised to do this is to create a helper function in my Application Controller, which formats an array into a bulleted list, which I then pass to, in my case, flash[:success]. This is clearly not the Rails Way because, i.a., my bulleted list gets encoded. That is, instead of getting:

  • Message 1
  • Message 2

I get:

<ul><li>Message 1</li><li>Message 2</li></ul>

I’m sure I could figure out a way to raw() the output, but isn’t there a simple way to get something like this working? Perhaps there’s an option to pass to flash[]? Something else?

  • 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-20T13:36:30+00:00Added an answer on May 20, 2026 at 1:36 pm

    I used render_to_string and a partial instead of a helper to achieve something similar.

    # app/controller/dogs_controller.rb
    def create
      @dog = Dog.new(params[:dog])
      @messages=[]
      if @dog.save
        @messages << "one"
        @messages << "two"
        flash[:notice] = render_to_string( :partial => "bulleted_flash")
        redirect_to(dogs_path)
      else
        render :action => 'new
      end
    end
    

    Then I format the array of flash messages in an HTML list

    # app/views/dogs/_bulleted_flash.html.erb
    <ol>
      <% @messages.each do |msg| %>
      <li><%= msg %></li>
      <% end %>
    </ol>
    

    Which produces the following HTML

    # http://0.0.0.0:3000/dogs
    <body>
      <div id="flash_notice">
        <ul>
          <li>one</li>
          <li>two</li>
        </ul>
      </div>
      ...
    </body>
    

    If you need to continue using a helper then I think you need to append the html_safe method to your string to prevent it from being encoded (which rails 3 does by default). Here is a question showing how to use html_safe in a similar fashion

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

Sidebar

Related Questions

I have an web address: http://www.example.com/org/companyA I want to be able to pass CompanyA
I want to be able to pass something into an SQL query to determine
I want to be able to pass in the path of a folder to
I want to be able to pass fields into the edit form when a
I want to be able to pass anything to a git command (maybe its
I have a List of about 20 items I want to display to the
ok, So I have multiple divs(7) which I want to toggle for show hide.
I have a sub (macro) in Excel that I want to be able to
I want to be able to pass a string (['parent_array']['child_array']) to a function that
I'm using LaTeX and BibTeX for an article, and I want to able to

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.