在我的Rails应用程序,我有以下型号Rails有许多在belongs_to的关系
class Member < ActiveRecord::Base
has_many :trainings
end
class Student < ActiveRecord::Base
belongs_to :member
has_many :trainings #maybe a through relationship here
end
class Teacher < ActiveRecord::Base
belongs_to :member
end
######编辑#################
class Training < ActiveRecord::Base
belongs_to :member #only member not student nor teacher
end
#############################
现在,我怎么能建立在我的培训学生管理员
class StudentsController < ApplicationController
def new
@student = Student.new
@student.trainings.build #### This is not working
end
end
感谢
你的'训练'模型在哪里? – 2015-02-07 08:14:40
也,它会帮助我们,如果你发布你收到的错误。 – 2015-02-07 08:21:40