diff options
author | Recursive Madman <recursive.madman@gmx.de> | 2014-11-26 15:05:34 +0100 |
---|---|---|
committer | Recursive Madman <recursive.madman@gmx.de> | 2014-11-26 15:07:35 +0100 |
commit | 59190c037999d302dd95b1f53f7049c2cec3f7b9 (patch) | |
tree | a70eb7939fd09259e47a11ac57ef7c077d2c4848 | |
parent | cb23d6a5ee34f6f7de15174cbd7b2920d6f4c956 (diff) | |
download | rails-59190c037999d302dd95b1f53f7049c2cec3f7b9.tar.gz rails-59190c037999d302dd95b1f53f7049c2cec3f7b9.tar.bz2 rails-59190c037999d302dd95b1f53f7049c2cec3f7b9.zip |
various error classes: added newlines & removed :nodoc: flag from public attribute.
-rw-r--r-- | activerecord/lib/active_record/errors.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/validations.rb | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index ca4fede7a2..14819aab54 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -196,6 +196,7 @@ module ActiveRecord # offending attribute. class AttributeAssignmentError < ActiveRecordError attr_reader :exception, :attribute + def initialize(message, exception, attribute) super(message) @exception = exception @@ -208,6 +209,7 @@ module ActiveRecord # objects, each corresponding to the error while assigning to an attribute. class MultiparameterAssignmentErrors < ActiveRecordError attr_reader :errors + def initialize(errors) @errors = errors end diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 7f7d49cdb4..a6c8ff7f3a 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -5,13 +5,14 @@ module ActiveRecord # +record+ method to retrieve the record which did not validate. # # begin - # complex_operation_that_calls_save!_internally + # complex_operation_that_internally_calls_save! # rescue ActiveRecord::RecordInvalid => invalid # puts invalid.record.errors # end class RecordInvalid < ActiveRecordError - attr_reader :record # :nodoc: - def initialize(record) # :nodoc: + attr_reader :record + + def initialize(record) @record = record errors = @record.errors.full_messages.join(", ") super(I18n.t(:"#{@record.class.i18n_scope}.errors.messages.record_invalid", :errors => errors, :default => :"errors.messages.record_invalid")) |