Module: FlashHelper
- Defined in:
- app/helpers/flash_helper.rb
Overview
This helper provides a method to include in the layout file in order to show an area presenting the flash messages sent by a controller. Note: Flash does refer to alert messages, not the vector graphics tool by adobe.
guides.rubyonrails.org/action_controller_overview.html#the-flash
Instance Method Summary collapse
-
#alert_field(type, message) ⇒ Object
Show a twitter bootstrap alert field.
- #announcement_flash ⇒ Object
- #flash_area ⇒ Object
Instance Method Details
#alert_field(type, message) ⇒ Object
Show a twitter bootstrap alert field. Possible types (bootstrap): info (blue), success (green), warning (yellow), danger (red) Possible types (rails): notice (-> info), alert (-> warning) Possible types (custom): error (-> danger)
22 23 24 25 26 27 28 |
# File 'app/helpers/flash_helper.rb', line 22 def alert_field(type, ) type = bootstrap_alert_type(type) # message = make_first_part_of_the_message_bold(message) content_tag :div, :class => "alert alert-#{type}" do + end.html_safe end |
#announcement_flash ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/flash_helper.rb', line 30 def announcement_flash announcement_file = File.join(Rails.root, "tmp", "announcement.md") if File.exist?(announcement_file) file_content = File.read(announcement_file) if file_content.present? content_tag :div, :class => 'alert alert-warning' do markup(file_content) end end end end |
#flash_area ⇒ Object
9 10 11 12 13 |
# File 'app/helpers/flash_helper.rb', line 9 def flash_area flash.collect do |type, | alert_field(type, ) end.join("\n").html_safe + announcement_flash end |