Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed that that multiparameter assignment doesn't work with aggregati…

…ons (closes #4620) [Lars Pind]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4188 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 8eb73f43e1f7eb6f7afa7838e64b259c81bc8a47 1 parent 6400367
@dhh dhh authored
View
4 activerecord/CHANGELOG
@@ -1,6 +1,8 @@
+*1.14.1* (April 6th, 2005)
+
* Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar]
-*1.14.1* (April 6th, 2005)
+* Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind]
* Enable Limit/Offset in Calculations (closes #4558) [lmarlow@yahoo.com]
View
2  activerecord/lib/active_record/base.rb
@@ -1988,7 +1988,7 @@ def assign_multiparameter_attributes(pairs)
def execute_callstack_for_multiparameter_attributes(callstack)
errors = []
callstack.each do |name, values|
- klass = (self.class.reflect_on_aggregation(name) || column_for_attribute(name)).klass
+ klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
if values.empty?
send(name + "=", nil)
else
View
9 activerecord/test/base_test.rb
@@ -2,6 +2,7 @@
require 'fixtures/topic'
require 'fixtures/reply'
require 'fixtures/company'
+require 'fixtures/customer'
require 'fixtures/developer'
require 'fixtures/project'
require 'fixtures/default'
@@ -721,6 +722,14 @@ def test_multiparameter_mass_assignment_protector
task.attributes = attributes
assert_equal time, task.starting
end
+
+ def test_multiparameter_assignment_of_aggregation
+ customer = Customer.new
+ address = Address.new("The Street", "The City", "The Country")
+ attributes = { "address(1)" => address.street, "address(2)" => address.city, "address(3)" => address.country }
+ customer.attributes = attributes
+ assert_equal address, customer.address
+ end
def test_attributes_on_dummy_time
# Oracle and SQL Server do not have a TIME datatype.
View
4 activerecord/test/fixtures/customer.rb
@@ -14,6 +14,10 @@ def initialize(street, city, country)
def close_to?(other_address)
city == other_address.city && country == other_address.country
end
+
+ def ==(other)
+ other.is_a?(self.class) && other.street == street && other.city == city && other.country == country
+ end
end
class Money

0 comments on commit 8eb73f4

Please sign in to comment.
Something went wrong with that request. Please try again.