module MostRelated

Constants

VERSION

Public Class Methods

join_table_values(many_to_many_assocation) click to toggle source
# File lib/most_related.rb, line 76
def self.join_table_values(many_to_many_assocation)
  if many_to_many_assocation.macro == :has_and_belongs_to_many
    join_table = many_to_many_assocation.join_table
    foreign_key = many_to_many_assocation.foreign_key
    association_foreign_key = many_to_many_assocation.association_foreign_key
  elsif many_to_many_assocation.macro == :has_many
    join_table = many_to_many_assocation.through_reflection.table_name
    foreign_key = many_to_many_assocation.through_reflection.foreign_key
    association_foreign_key = many_to_many_assocation.foreign_key
  end
  [join_table, foreign_key, association_foreign_key]
end

Public Instance Methods