Skip to content
Benjamin Sigidi edited this page Jul 16, 2014 · 2 revisions

Nearly all rails apps have flash messages. Concise comes with various classes that can be used to change the color of text.

For more information see our documentation on Colors or to learn more about Flash see Ruby on Rails Guides.

Following Ryan Boland's way of creating flash messages. We will create a helper method that can be used across your application.

Layout Helper

app/helpers/layout_helper.rb

module LayoutHelper
  def flash_messages(opts={})
    @layout_flash = opts.fetch(:layout_flash) { true }

    capture do
      flash.each do |name, msg|
        concat content_tag(:p, msg, class: "flash_#{name}")
      end
    end
  end

  def show_layout_flash?
    @layout_flash.nil? ? true : @layout_flash
  end
end

Application Layout

app/views/layouts/application.html.haml or anywhere else where you want the flash message to appear.

  = flash_messages if show_layout_flash?

Custom CSS

app/assets/stylesheets/custom.css.scss The best way to extend Concise is to create a custom.css.scss file and import concise

@import "concise";

// Flash messages
.flash_notice {
  @extend .color-green;
}

.flash_alert, .flash_error{
  @extend .color-red;
}
.flash_warning {
  @extend .color-yellow;
}
Clone this wiki locally