Module: ApplicationHelper
- Defined in:
- lib/generators/templates/application_helper.rb
Constant Summary collapse
- ALERT_TYPES =
[:error, :info, :success, :warning]
Instance Method Summary collapse
Instance Method Details
#bootstrap_flash ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/templates/application_helper.rb', line 5 def bootstrap_flash = [] flash.each do |type, | # Skip empty messages, e.g. for devise messages set to nothing in a locale file. next if .blank? type = :success if type == :notice type = :error if type == :alert next unless ALERT_TYPES.include?(type) Array().each do |msg| text = content_tag(:div, content_tag(:button, raw("×"), :class => "close", "data-dismiss" => "alert") + msg.html_safe, :class => "alert fade in alert-#{type}") << text if msg end end .join("\n").html_safe end |
#errors_for(object) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/templates/application_helper.rb', line 25 def errors_for(object) = [] object.errors..each do |msg| tag = content_tag(:div, content_tag(:button, raw("×"), :class => "close", "data-dismiss" => "alert", 'aria-hidden' => 'true') + msg.html_safe, :class => "alert alert-dismissable alert-danger") << tag end .join("\n").html_safe end |