Skip to content
Browse files

expanded rdoc on source_reflection method

  • Loading branch information...
1 parent 1bf4088 commit e87a513f4288634cdbd69842717162d2469c66da @neerajdotname neerajdotname committed
Showing with 10 additions and 0 deletions.
  1. +10 −0 activerecord/lib/active_record/reflection.rb
View
10 activerecord/lib/active_record/reflection.rb
@@ -401,6 +401,16 @@ class ThroughReflection < AssociationReflection #:nodoc:
# has_many :tags, through: :taggings
# end
#
+ # class Tagging < ActiveRecord::Base
+ # belongs_to :post
+ # belongs_to :tag
+ # end
+ #
+ # tags_reflection = Post.reflect_on_association(:tags)
+ #
+ # taggings_reflection = tags_reflection.source_reflection
+ # #=> <ActiveRecord::Reflection::AssociationReflection: @macro=:belongs_to, @name=:tag, @active_record=Tagging, @plural_name="tags">
+ #
def source_reflection
@source_reflection ||= source_reflection_names.collect { |name| through_reflection.klass.reflect_on_association(name) }.compact.first
end

0 comments on commit e87a513

Please sign in to comment.
Something went wrong with that request. Please try again.