我得到兩個表,一個叫Teacher
,另一個叫Teacher_Type
。 A Teacher
可以有許多Teach_Types
,即約翰史密斯先生是模塊負責人,導師和講師(3位教師類型)。TeachersController中的ActiveRecord :: StatementInvalid#show和SQLite3 :: SQLException:沒有這樣的列錯誤
我有他們和他們各自的模型之間的以下關聯:
class Teacher < ActiveRecord::Base
has_and_belongs_to_many :teacher_types
attr_accessible :first_name, :last_name, :teacher_type_ids
class TeacherType < ActiveRecord::Base
has_and_belongs_to_many :teachers
attr_accessible :title
end
所以,現在當我嘗試創建一個新的Teacher
與連接到它的一些Teacher_Types
,就像這樣:
但是,當我按下「創建教師」按鈕時,出現以下錯誤消息:
我創造了一些Teachers
過,但離開了Teacher_Types
空的,所以即使當我嘗試去localhost:3000/teachers/3
,我收到以下錯誤信息(包括SQLite的瀏覽器,看看有什麼Teachers
表內)
所以我不知道我要去哪裏錯在這裏......
我的關聯是不正確的?
做ü有'teachers_teacher_types'或'teacher_types_teachers'表? – codeit 2013-03-08 19:22:29