我有以下型號 -Rails的has_and_belongs_to_many創建/插入不起作用
class Employee < ActiveRecord::Base
has_and_belongs_to_many :surveys, join_table: 'employee_surveys'
end
class Survey < ActiveRecord::Base
has_and_belongs_to_many :employees, join_table: 'employee_surveys'
end
當我做Employee.first.surveys.create(name: "New Survey")
它會產生一個錯誤,抱怨employee_id
是null
?
有什麼確切的錯誤/回溯? –