【发布时间】:2015-06-05 08:50:28
【问题描述】:
您好,我实际上正在努力构建一个在 Rails 4 上实现出勤模型的 Rails 4 应用程序,我在 stackoverflow 上发现了两个问题,但它们是在 2012 年发布的,当我尝试关注它们时它失败了。
这是我得到的最接近的on stackoverflow
编辑:我已经有了教室视图并列出了学生。并且可以将学生分配到教室,但问题是让学生进入一个新的 attsheet 并将他们保存到 attendance
这是我现在拥有的
# Attendance
# take student as a single entry for :attsheet and
# has a :attended (boolean) and remarks as well
class Attendance < ActiveRecord::Base
belongs_to :student
belongs_to :attsheet
end
#Attsheet which means attendance sheet
#has :post_date and :remark
class Attsheet < ActiveRecord::Base
belongs_to :classroom
has_many :attendances
accepts_nested_attributes_for :attendances
end
class Student < ActiveRecord::Base
belongs_to :school
has_and_belongs_to_many :classrooms
has_many :attendances
end
class Classroom < ActiveRecord::Base
belongs_to :school
has_and_belongs_to_many :students
has_many :attsheets
validates :class_name, presence: true
end
我希望教室能够为每个学生创建新的出勤或查看出勤档案。
我现在可以在课堂上执行此操作,但我不知道控制器和视图接下来要做什么
$ = link_to "New Attendance", new_school_classroom_attsheet_path(@school, @classroom, @attsheet)
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 model