Class: FancyErrors
- Inherits:
-
ActiveRecord::Errors
- Object
- ActiveRecord::Errors
- FancyErrors
- Defined in:
- lib/fancy_errors.rb
Instance Method Summary collapse
Instance Method Details
#full_messages(options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/fancy_errors.rb', line 2 def ( = {}) if [:order] && order = [:order].map {|a| a.to_s } # add attrs specified in order ordered_attrs = order & @errors.keys ordered_attrs += @errors.keys - order end (ordered_attrs||@errors.keys).inject([]) do |, a| .concat((a)) end end |
#full_messages_on(attribute) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fancy_errors.rb', line 14 def (attribute) (@errors[attribute.to_s] || []).inject([]) do |, msg| if attribute.to_s == 'base' << msg elsif msg =~ /^\^/ << msg[1..-1] else attr_name = @base.class.human_attribute_name(attribute) << attr_name + I18n.t('activerecord.errors.format.separator', :default => ' ') + msg end end end |