我得到两个表,一个叫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