Sha256: 6f04b5bd81ab2dcdfff6bca9990c5006694f05d59fe68dbbe1a68bb54dfbe8d2
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
module SimpleForm class ErrorNotification delegate :object, :object_name, :template, :to => :@builder def initialize(builder, options) @builder = builder @message = options.delete(:message) @options = options end def render if has_errors? template.content_tag(error_notification_tag, error_message, html_options) end end protected def errors object.errors end def has_errors? object && object.respond_to?(:errors) && errors.present? end def error_message (@message || translate_error_notification).html_safe end def error_notification_tag SimpleForm.error_notification_tag end def html_options @options[:class] = "#{SimpleForm.error_notification_class} #{@options[:class]}".strip @options end def translate_error_notification lookups = [] lookups << :"#{object_name}" lookups << :default_message lookups << "Some errors were found, please take a look:" I18n.t(lookups.shift, :scope => :"simple_form.error_notification", :default => lookups) end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
ehoch_simple_form-2.0.2.dev | lib/simple_form/error_notification.rb |
simple_form-2.0.1 | lib/simple_form/error_notification.rb |
simple_form-2.0.0 | lib/simple_form/error_notification.rb |