Module: InsteddRails::InsteddAppHelper
- Defined in:
- app/helpers/instedd_rails/instedd_app_helper.rb
Instance Method Summary collapse
Instance Method Details
#errors_for(object, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/instedd_rails/instedd_app_helper.rb', line 23 def errors_for(object, = {}) unless object.nil? if object.errors.any? # TODO change on rails 3.1 to ActiveModel::Naming.param_key(object) object_name = [:as].try(:to_s) || ActiveModel::Naming.singular(object) content_tag :div, :class => "box error_description #{[:class] || 'w60'}" do (content_tag :h2 do t("errors_prohibited_being_saved", default: "%{errors_count} prohibited this %{object_name} from being saved:") % {errors_count: pluralize(object.errors.count, 'error'), object_name: object_name.humanize} end) \ + \ (content_tag :ul do raw object.errors..map { |msg| content_tag(:li, msg) }.join end) end end end end |
#flash_message ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/instedd_rails/instedd_app_helper.rb', line 3 def res = nil keys = { :notice => 'flash_notice', :error => 'flash_error', :alert => 'flash_error' } keys.each do |key, value| if flash[key] html_option = { :class => "flash #{value}" } html_option[:'data-hide-timeout'] = 3000 if key == :notice res = content_tag :div, html_option do content_tag :div do flash[key] end end end end res end |