Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove chain delegate

  • Loading branch information...
commit a8775bba58fb9dd3b0a51a812fa6ec43d8084ff6 1 parent 279212d
@tenderlove tenderlove authored
View
11 activerecord/lib/active_record/associations/association_scope.rb
@@ -4,7 +4,6 @@ class AssociationScope #:nodoc:
attr_reader :association, :alias_tracker
delegate :klass, :reflection, :to => :association
- delegate :chain, :to => :reflection
def initialize(association)
@association = association
@@ -16,7 +15,9 @@ def scope
scope.extending! Array(reflection.options[:extend])
owner = association.owner
- add_constraints(scope, owner, reflection.scope_chain)
+ scope_chain = reflection.scope_chain
+ chain = reflection.chain
+ add_constraints(scope, owner, scope_chain, chain)
end
def join_type
@@ -25,7 +26,7 @@ def join_type
private
- def construct_tables
+ def construct_tables(chain)
chain.map do |reflection|
alias_tracker.aliased_table_for(
table_name_for(reflection),
@@ -61,8 +62,8 @@ def bind(scope, table_name, column_name, value)
bind_value scope, column, value
end
- def add_constraints(scope, owner, scope_chain)
- tables = construct_tables
+ def add_constraints(scope, owner, scope_chain, chain)
+ tables = construct_tables(chain)
chain.each_with_index do |reflection, i|
table, foreign_table = tables.shift, tables.first
Please sign in to comment.
Something went wrong with that request. Please try again.