aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/errors.rb
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2015-02-25 15:14:43 +0100
committerRobin Dupret <robin.dupret@gmail.com>2015-02-26 15:40:03 +0100
commit95c2fc967987e5dffa89a32c81bca736c7ba964d (patch)
treefb9607d98d956beb4037b2575de1b529f94107a9 /activemodel/lib/active_model/errors.rb
parent803ef74f9bbcbc71af12060157a996f7b65e24db (diff)
downloadrails-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/errors.rb')
-rw-r--r--activemodel/lib/active_model/errors.rb11
1 files changed, 11 insertions, 0 deletions
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