aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/aggregations.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-23 17:29:42 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-23 17:29:42 +0000
commitc220e558be33e30a7946d3604d45ba671b2e7c31 (patch)
tree7a0ea36ef2741a900a74edec20b8a9884f7fff75 /activerecord/lib/active_record/aggregations.rb
parent562b398fd729b05bfde4da90b91efc24dbbac49d (diff)
downloadrails-c220e558be33e30a7946d3604d45ba671b2e7c31.tar.gz
rails-c220e558be33e30a7946d3604d45ba671b2e7c31.tar.bz2
rails-c220e558be33e30a7946d3604d45ba671b2e7c31.zip
Assigning nil to a composed_of aggregate also sets its immediate value to nil. Closes #9843.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8002 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/aggregations.rb')
-rw-r--r--activerecord/lib/active_record/aggregations.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index 8c3cdc3c11..8ee9d8368d 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -148,7 +148,7 @@ module ActiveRecord
mapping = (Array === mapping.first ? mapping : [ mapping ])
allow_nil_condition = if allow_nil
- mapping.collect { |pair| "!read_attribute(\"#{pair.first}\").nil?"}.join(" && ")
+ mapping.collect { |pair| "!read_attribute(\"#{pair.first}\").nil?"}.join(" || ")
else
"true"
end
@@ -169,10 +169,10 @@ module ActiveRecord
if allow_nil
module_eval <<-end_eval, __FILE__, __LINE__
def #{name}=(part)
+ @#{name} = part.freeze
if part.nil?
#{mapping.collect { |pair| "@attributes[\"#{pair.first}\"] = nil" }.join("\n")}
else
- @#{name} = part.freeze
#{mapping.collect { |pair| "@attributes[\"#{pair.first}\"] = part.#{pair.last}" }.join("\n")}
end
end