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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:10:46+00:00 2026-05-30T22:10:46+00:00

I am integrating twitter bootstrap css into my application. Going along just fine,but I

  • 0

I am integrating twitter bootstrap css into my application. Going along just fine,but I don’t know how to customize the css and wrappers for my flash messages.

I would like my flash messages to be formatted with the default Bootstrap classes:

    <div class="alert-message error">
      <a class="close" href="#">×</a>
      <p><strong>Oh snap!</strong> Change this and that and <a href="#">try again</a>.</p>
    </div>

Currently I output my flash messages with:

<% flash.each do |name, msg| %>
    <%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>

Is there an easy way to run a little switch that would make :notification or other rails flash messages map to the classes in bootcamp, like info?

  • 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-30T22:10:47+00:00Added an answer on May 30, 2026 at 10:10 pm

    My answer for Bootstrap 2.0 starts from the helpful answer by @Railslerner but uses different code in the partial.

    app/helpers/application_helper.rb (same as @Railslerner’s answer)

    module ApplicationHelper
      def flash_class(level)
        case level.to_sym
        when :notice then "alert alert-info"
        when :success then "alert alert-success"
        when :error then "alert alert-error"
        when :alert then "alert alert-error"
        end
      end
    end
    

    Somewhere in app/views/layouts/application.html.erb:

    <%= render 'layouts/flash_messages' %>
    

    app/views/layouts/_flash_messages.html.erb

    <div>
      <% flash.each do |key, value| %>
        <div class="<%= flash_class(key) %> fade in">
          <a href="#" data-dismiss="alert" class="close">×</a>
          <%= value %>
        </div>
      <% end %>
    </div>
    

    Differences:

    • Does not loop through different error levels each time it is called.
    • Instead loops through the flash hash if the hash contains messages (following the
      approach in Michael Hartl’s Rails Tutorial).
    • Does not use the <p> tag, no longer required in Bootstrap 2.0.

    Remember to include bootstrap-alert.js so the fade and close functionality will work. If you’re using the bootstap-sass gem, add this line to app/assets/javascripts/application.js:

    //= require bootstrap-alert
    

    Update 8/9/2012: Folders updated. I actually put everything except the helper under app/views/layouts since flash_messages is only used in app/views/layouts/application.html.erb.

    Update 6/5/2015: After updating to Rails 4.2, I discovered that level was (at least sometimes) coming in as a String and failing to match the case statement in the ApplicationHelper. Changed that to level.to_sym.

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

Sidebar

Related Questions

I am currently integrating twitter bootstrap. My application layout currently includes my flash messages
I followed the below link to integrate Twitter into my application. http://icodeblog.com/2009/07/09/integrating-twitter-into-your-applications/ It was
i am integrating twitter application in my application my application is created in xcode
i am integrating twitter in my iphone application.when i am entering the username and
i am integrating twitter in my iphone music application.i.e when a user clicks a
i am integrating twitter in my iphone music application.When the user enters username and
i am creating a music application in iphone where i am integrating twitter in
I originally used this tutorial - http://icodeblog.com/2009/07/09/integrating-twitter-into-your-applications/ to put twitter into my app. It
I'm looking into integrating elasticsearch into my spring-jpa driven application. For this purpose the
So im integrating this Twitter widget into xhtml. ( http://help.twitter.com/forums/10711/entries/15354 ) The code is:

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.