0
我创建了许多到许多教师和Sclass的协会。 ClassTeacher是连接表名称。访问多对多关系中的数据
class Teacher < ActiveRecord::Base
has_many :class_teachers
has_many :Sclasses, :through => :class_teachers
attr_accessible :teacher_id
attr_accessible :tname
attr_accessible :mob
attr_accessible :email
end
class Sclass < ActiveRecord::Base
set_primary_key :year
has_many :class_teachers
has_many :teachers, :through => :class_teachers
attr_accessible :year
end
class ClassTeacher < ActiveRecord::Base
belongs_to :teacher
belongs_to :sclass
attr_accessible :year
attr_accessible :teacher_id
end
我有tlist.html.erb,tnew.html.erb在查看 - >文件夹的教师,同样我也slist.html.erb,snew.html.erb鉴于 - > sclasses文件夹。
当我为老师添加一条记录时,它也应该要求多年并保存记录。同样,一年它应该要求teacher_ids并保存记录。我该怎么做?这些记录将保存在哪里?