diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-31 16:35:58 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-31 16:35:58 -0700 |
commit | 46a458206f1117b87e672bc5aae046eaa832ee00 (patch) | |
tree | b2692b98da56d23394605594c9dea5610719e7e0 /activerecord/lib/active_record/base.rb | |
parent | a540725f0d3439ea3b0f938d04ceed87d3690d9d (diff) | |
parent | 0b9bfbdebf402f4a149359a069dbeb05ea989b14 (diff) | |
download | rails-46a458206f1117b87e672bc5aae046eaa832ee00.tar.gz rails-46a458206f1117b87e672bc5aae046eaa832ee00.tar.bz2 rails-46a458206f1117b87e672bc5aae046eaa832ee00.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r--[-rwxr-xr-x] | activerecord/lib/active_record/base.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 9cb64223e2..29c2995334 100755..100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -122,6 +122,10 @@ module ActiveRecord #:nodoc: class MissingAttributeError < NoMethodError end + # Raised when unknown attributes are supplied via mass assignment. + class UnknownAttributeError < NoMethodError + end + # Raised when an error occurred while doing a mass assignment to an attribute through the # <tt>attributes=</tt> method. The exception has an +attribute+ property that is the name of the # offending attribute. @@ -2400,7 +2404,11 @@ module ActiveRecord #:nodoc: attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes attributes.each do |k, v| - k.include?("(") ? multi_parameter_attributes << [ k, v ] : send(k + "=", v) + if k.include?("(") + multi_parameter_attributes << [ k, v ] + else + respond_to?(:"#{k}=") ? send(:"#{k}=", v) : raise(UnknownAttributeError, "unknown attribute: #{k}") + end end assign_multiparameter_attributes(multi_parameter_attributes) |