aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2011-06-13 13:02:51 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2011-06-13 13:02:51 +0100
commit5d655aabcb47a68e7ce1dfb60222e951a6d30169 (patch)
treed48691fbdf90430175a2132c18771be2644857bc /activerecord/lib/active_record/base.rb
parent987afa583e06a186a2c7235931dfd18d8d2d63a3 (diff)
downloadrails-5d655aabcb47a68e7ce1dfb60222e951a6d30169.tar.gz
rails-5d655aabcb47a68e7ce1dfb60222e951a6d30169.tar.bz2
rails-5d655aabcb47a68e7ce1dfb60222e951a6d30169.zip
Pass mass-assignment options to nested models - closes #1673.
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r--activerecord/lib/active_record/base.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 2f283ff6bc..08cccf1da2 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1717,10 +1717,13 @@ MSG
attributes.each do |k, v|
if k.include?("(")
multi_parameter_attributes << [ k, v ]
- elsif respond_to?("#{k}=")
- send("#{k}=", v)
else
- raise(UnknownAttributeError, "unknown attribute: #{k}")
+ method_name = "#{k}="
+ if respond_to?(method_name)
+ method(method_name).arity == -2 ? send(method_name, v, options) : send(method_name, v)
+ else
+ raise(UnknownAttributeError, "unknown attribute: #{k}")
+ end
end
end