aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-03-02 09:21:42 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-03-02 09:21:42 -0700
commitc0584ea0346062982cfe3c776c826ea1b026a8ac (patch)
tree16bc948bd6159fd44385127ceb5a7f11c5c074ef /activemodel/lib
parent53333935347a1f1ca6dc57d1f7ddd9663c78d037 (diff)
parent95c2fc967987e5dffa89a32c81bca736c7ba964d (diff)
downloadrails-c0584ea0346062982cfe3c776c826ea1b026a8ac.tar.gz
rails-c0584ea0346062982cfe3c776c826ea1b026a8ac.tar.bz2
rails-c0584ea0346062982cfe3c776c826ea1b026a8ac.zip
Merge pull request #19077 from robin850/unknown-attribute-error
Move `UnknownAttributeError` to a more sane namespace
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model.rb1
-rw-r--r--activemodel/lib/active_model/attribute_assignment.rb11
-rw-r--r--activemodel/lib/active_model/errors.rb11
3 files changed, 12 insertions, 11 deletions
diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb
index 58fe08cc11..8aa1b6f664 100644
--- a/activemodel/lib/active_model.rb
+++ b/activemodel/lib/active_model.rb
@@ -50,6 +50,7 @@ module ActiveModel
eager_autoload do
autoload :Errors
autoload :StrictValidationFailed, 'active_model/errors'
+ autoload :UnknownAttributeError, 'active_model/errors'
end
module Serializers
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 8326853879..f324788979 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -524,4 +524,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