mysql - How to join tables with no primary key in rails? -


i have 2 tables both have no primary key. below 2 tables structure.

enter image description here

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??


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -