Sha256: 9fab31f69b7cb484adff1e8b8d69dea262be667d0c2fa258daf9d0dfdf5c06b4
Contents?: true
Size: 1.34 KB
Versions: 5
Compression:
Stored size: 1.34 KB
Contents
module InsteddRails module InsteddAppHelper def flash_message 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 def errors_for(object, options = {}) unless object.nil? if object.errors.any? # TODO change on rails 3.1 to ActiveModel::Naming.param_key(object) object_name = options[:as].try(:to_s) || ActiveModel::Naming.singular(object) content_tag :div, :class => "box error_description #{options[: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.full_messages.map { |msg| content_tag(:li, msg) }.join end) end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems