Hi I'm actually struggling with building a Rails 4 application implementing an attendance model on rails 4, I found maybe two question on stackoverflow but they're posted in 2012 and it failed when i tried following them.
This is the closest one i got on stackoverflow
Edit: I already have a view of classroom and list out the students. And could assign students into the classroom but the problem would be to GET the students into a new attsheet and saving them into attendance
Here's what I currently have now
# 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
I want the classroom to be able to create a new attendance or view attendance archives for each student.
I am able to do this in classroom right now but I'm stuck at what to do next for the controller and view
$ = link_to "New Attendance", new_school_classroom_attsheet_path(@school, @classroom, @attsheet)
I found the solution by doing
I changed attsheet to attendance_list
with simple fields