1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

doc: ActiveRecord::Reflection::AssociationReflection#through_reflection

Added documentation demonstrating the use of #through_reflection for
finding intervening reflection objects for HasManyThrough
and HasOneThrough.
This commit is contained in:
Jack Danger Canty 2008-05-06 23:35:05 -07:00
parent 405de50af0
commit f81d771f06

View file

@ -153,6 +153,17 @@ module ActiveRecord
end end
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 def through_reflection
@through_reflection ||= options[:through] ? active_record.reflect_on_association(options[:through]) : false @through_reflection ||= options[:through] ? active_record.reflect_on_association(options[:through]) : false
end end