diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2015-02-25 15:14:43 +0100 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2015-02-26 15:40:03 +0100 |
commit | 95c2fc967987e5dffa89a32c81bca736c7ba964d (patch) | |
tree | fb9607d98d956beb4037b2575de1b529f94107a9 /activemodel/lib/active_model | |
parent | 803ef74f9bbcbc71af12060157a996f7b65e24db (diff) | |
download | rails-95c2fc967987e5dffa89a32c81bca736c7ba964d.tar.gz rails-95c2fc967987e5dffa89a32c81bca736c7ba964d.tar.bz2 rails-95c2fc967987e5dffa89a32c81bca736c7ba964d.zip |
Follow-up to #10776
The name `ActiveModel::AttributeAssignment::UnknownAttributeError` is
too implementation specific so let's move the constant directly under
the ActiveModel namespace.
Also since this constant used to be under the ActiveRecord namespace, to
make the upgrade path easier, let's avoid raising the former constant
when we deal with this error on the Active Record side.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/attribute_assignment.rb | 11 | ||||
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 11 |
2 files changed, 11 insertions, 11 deletions
diff --git a/activemodel/lib/active_model/attribute_assignment.rb b/activemodel/lib/active_model/attribute_assignment.rb index 356421476c..087d11f708 100644 --- a/activemodel/lib/active_model/attribute_assignment.rb +++ b/activemodel/lib/active_model/attribute_assignment.rb @@ -48,16 +48,5 @@ module ActiveModel raise UnknownAttributeError.new(self, k) end end - - # Raised when unknown attributes are supplied via mass assignment. - class UnknownAttributeError < NoMethodError - attr_reader :record, :attribute - - def initialize(record, attribute) - @record = record - @attribute = attribute - super("unknown attribute '#{attribute}' for #{@record.class}.") - end - end end end diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 8334747615..8a21332cc2 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -525,4 +525,15 @@ module ActiveModel # # => ActiveModel::StrictValidationFailed: Name can't be blank class StrictValidationFailed < StandardError end + + # Raised when unknown attributes are supplied via mass assignment. + class UnknownAttributeError < NoMethodError + attr_reader :record, :attribute + + def initialize(record, attribute) + @record = record + @attribute = attribute + super("unknown attribute '#{attribute}' for #{@record.class}.") + end + end end |