0
我目前使用的是舊數據庫,我有2個模型:提交和發佈。Ruby on Rails - has_and_belongs_to_many relationship
class Submission < ActiveRecord::Base
has_and_belongs_to_many :publications, :join_table => "ish_sub_pub", :association_foreign_key => "SLN_PUB_FK"
end
class Publication < ActiveRecord::Base
has_and_belongs_to_many :submissions, :join_table => "ish_sub_pub" ,
:association_foreign_key => "SLN_SUBMISSION_FK"
end
當我創建一個新的提交,我希望能夠發佈以它關聯,爲此我需要在連接表,「ish_sub_pub」添加一個新的記錄。
我對如何繼續添加發布到提交有點困惑。
非常感謝您的幫助