Method: LolDba::RelationInspector#get_through_foreign_key
- Defined in:
- lib/lol_dba/index_finding/relation_inspector.rb
#get_through_foreign_key(target_class, reflection_options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lol_dba/index_finding/relation_inspector.rb', line 11 def get_through_foreign_key(target_class, ) # has_many :through reflection = target_class.reflections[.[:through].to_s] # has_and_belongs_to_many reflection ||= # Guess foreign key? if reflection.[:foreign_key] reflection.[:foreign_key] else "#{target_class.name.tableize.singularize}_id" end end |