mysql - How to join tables with no primary key in rails? -
    i have 2 tables both have no primary key. below 2 tables structure.     how can use in join table on column date in rails ?   meanwhile, date columns not unique in both tables.          from understanding (which may wrong), need use primary key, in order identify foreign keys in rails     foreign keys   however, try using association_foreign_key  , foreign_key  arguments in associations definitions ( only works habtm ):   #app/models/table_a.rb class tablea < activerecord::base     has_and_belongs_to_many :table_b, foreign_key: "country_id", association_foreign_key: "hour" end  #app/models/table_b.rb class tablea < activerecord::base     has_and_belongs_to_many :table_a, foreign_key: "hour", association_foreign_key: "country_id"  end  table_as_table_bs hour | country_id   would difficult include id  column in tables??