This method is deprecated or moved on the latest stable version.
The last existing version (v5.0.0.1) is shown here.
scope_chain()
public
Consider the following example:
class Personhas_many:articleshas_many:comment_tags,through::articlesendclass Articlehas_many:commentshas_many:comment_tags,through::comments,source::tagsendclass Commenthas_many:tagsend
There may be scopes on Person.comment_tags, Article.comment_tags and/or
Comment.tags, but only Comment.tags will be represented in the #chain.
So this method creates an array of scopes corresponding to the chain.
# File activerecord/lib/active_record/reflection.rb, line 804
def scope_chain
@scope_chain ||= begin
scope_chain = source_reflection.scope_chain.map(&:dup)
# Add to it the scope from this reflection (if any)
scope_chain.first << scope if scope
through_scope_chain = through_reflection.scope_chain.map(&:dup)
if options[:source_type]
type = foreign_type
source_type = options[:source_type]
through_scope_chain.first << lambda { |object|
where(type => source_type)
}
end
# Recursively fill out the rest of the array from the through reflection
scope_chain + through_scope_chain
end
end