Skip to content

Commit

Permalink
doc: ActiveRecord::Reflection::AssociationReflection#through_reflection
Browse files Browse the repository at this point in the history
Added documentation demonstrating the use of #through_reflection for
finding intervening reflection objects for HasManyThrough
and HasOneThrough.
  • Loading branch information
JackDanger committed May 7, 2008
1 parent 405de50 commit f81d771
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions activerecord/lib/active_record/reflection.rb
Expand Up @@ -153,6 +153,17 @@ def counter_cache_column
end
end

# Returns the AssociationReflection object specified in the <tt>:through</tt> option
# of a HasMantThrough or HasOneThrough association. Example:
#
# class Post < ActiveRecord::Base
# has_many :taggings
# has_many :tags, :through => :taggings
# end
#
# tags_reflection = Post.reflect_on_association(:tags)
# taggings_reflection = tags_reflection.through_reflection
#
def through_reflection
@through_reflection ||= options[:through] ? active_record.reflect_on_association(options[:through]) : false
end
Expand Down

0 comments on commit f81d771

Please sign in to comment.