class SimpleForm::ErrorNotification

Public Class Methods

new(builder, options) click to toggle source
# File lib/simple_form/error_notification.rb, line 5
def initialize(builder, options)
  @builder = builder
  @message = options.delete(:message)
  @options = options
end

Public Instance Methods

render() click to toggle source
# File lib/simple_form/error_notification.rb, line 11
def render
  if has_errors?
    template.content_tag(error_notification_tag, error_message, html_options)
  end
end

Protected Instance Methods

error_message() click to toggle source
# File lib/simple_form/error_notification.rb, line 27
def error_message
  (@message || translate_error_notification).html_safe
end
error_notification_tag() click to toggle source
# File lib/simple_form/error_notification.rb, line 31
def error_notification_tag
  SimpleForm.error_notification_tag
end
errors() click to toggle source
# File lib/simple_form/error_notification.rb, line 19
def errors
  object.errors
end
has_errors?() click to toggle source
# File lib/simple_form/error_notification.rb, line 23
def has_errors?
  object && object.respond_to?(:errors) && errors.present?
end
html_options() click to toggle source
# File lib/simple_form/error_notification.rb, line 35
def html_options
  @options[:class] = "#{SimpleForm.error_notification_class} #{@options[:class]}".strip
  @options
end
translate_error_notification() click to toggle source
# File lib/simple_form/error_notification.rb, line 40
def translate_error_notification
  lookups = []
  lookups << :"#{object_name}"
  lookups << :default_message
  lookups << "Please review the problems below:"
  I18n.t(lookups.shift, :scope => :"simple_form.error_notification", :default => lookups)
end