Sha256: 061a1086553885554f6dde179dc57c9153d08deb61ed84090997e6b46f509589
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module SimpleFormWithClientValidation 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 SimpleFormWithClientValidation.error_notification_tag end def html_options @options[:class] = "#{SimpleFormWithClientValidation.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
2 entries across 2 versions & 1 rubygems