diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-12 09:55:32 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-12-12 09:55:32 +0000 |
commit | 9a98c766e045aebc2ef6d5b716936b73407f095d (patch) | |
tree | 899834482c828f31a89ebc7bb6e19cbe0b5f18d3 /activerecord/lib/active_record/associations/class_methods/join_dependency.rb | |
parent | 3a7f43ca6ecf1735e1a82d4a68ac8f62b5cf2fcf (diff) | |
parent | 307443972c5f6de959a5401eec76ca327484b10c (diff) | |
download | rails-9a98c766e045aebc2ef6d5b716936b73407f095d.tar.gz rails-9a98c766e045aebc2ef6d5b716936b73407f095d.tar.bz2 rails-9a98c766e045aebc2ef6d5b716936b73407f095d.zip |
Merge branch 'master' into nested_has_many_through
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/associations/class_methods/join_dependency.rb
activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
activerecord/lib/active_record/associations/has_many_through_association.rb
Diffstat (limited to 'activerecord/lib/active_record/associations/class_methods/join_dependency.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/class_methods/join_dependency.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb index ce20420aad..78b634a26c 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb @@ -6,13 +6,15 @@ module ActiveRecord module Associations module ClassMethods class JoinDependency # :nodoc: - attr_reader :join_parts, :reflections, :alias_tracker + attr_reader :join_parts, :reflections, :alias_tracker, :active_record def initialize(base, associations, joins) - @join_parts = [JoinBase.new(base, joins)] - @associations = {} - @reflections = [] - @alias_tracker = AliasTracker.new(joins) + @active_record = base + @table_joins = joins + @join_parts = [JoinBase.new(base)] + @associations = {} + @reflections = [] + @alias_tracker = AliasTracker.new(joins) @alias_tracker.aliased_name_for(base.table_name) # Updates the count for base.table_name to 1 build(associations) end @@ -49,11 +51,11 @@ module ActiveRecord records = rows.map { |model| primary_id = model[primary_key] parent = parents[primary_id] ||= join_base.instantiate(model) - construct(parent, @associations, join_associations.dup, model) + construct(parent, @associations, join_associations, model) parent }.uniq - remove_duplicate_results!(join_base.active_record, records, @associations) + remove_duplicate_results!(active_record, records, @associations) records end @@ -122,7 +124,7 @@ module ActiveRecord build(association, parent, join_type) end when Hash - associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name| + associations.keys.sort_by { |a| a.to_s }.each do |name| join_association = build(name, parent, join_type) build(associations[name], join_association, join_type) end |