To get these nice Twitter Bootstrap alerts to show up in your Rails application


Emit them from your Rails app like this.


 class SomeController < ApplicationController

  before_action :last_page

  def what_is_automated_testing
    flash[:success] = 'Success'
    flash[:info] = 'Info'
    flash[:warning] = 'Warning'
    flash[:danger] = 'Danger'
    render layout: "static_page_with_sidebar"

Now, if you have Twitter bootstrap correctly configured, you should see this.


If you are wondering why you don’t see this styling with the rest of your application, it’s because Rails by default doesn’t use this hashes (success, info, warning, etc) for it’s messages. It uses ‘notice’ and others instead (though some may overlap) which is defined in the defaul scaffold.scss so beware of that.

Happy styling!

Links that help