Method: ActiveRecord::Reflection::ThroughReflection#source_reflection
- Defined in:
- activerecord/lib/active_record/reflection.rb
#source_reflection ⇒ Object
Returns the source of the through reflection. It checks both a singularized and pluralized form for :belongs_to
or :has_many
.
class Post < ActiveRecord::Base
has_many :taggings
has_many :tags, through: :taggings
end
class Tagging < ActiveRecord::Base
belongs_to :post
belongs_to :tag
end
= Post.reflect_on_association(:tags)
.source_reflection
# => <ActiveRecord::Reflection::BelongsToReflection: @name=:tag, @active_record=Tagging, @plural_name="tags">
797 798 799 |
# File 'activerecord/lib/active_record/reflection.rb', line 797 def source_reflection through_reflection.klass._reflect_on_association(source_reflection_name) end |