Closed beisert1 closed 10 years ago
The current join that was given for absent only returns those who have had attendances in the past. This is the code I used to get my absent functioning correctly, it is a streamlined version of Jaime's.
def self.absent(date)
attendances = Attendance.where(date)
students = attendances.collect{ |a| a.student_id }
Student.where.not(id: students)
end
This is a cleaner way of writing (4 simple loops)
<% Student.in_seat(1, Date.today).each do |student| %>
instead of what you have which is
<% @seatOne = Student.in_seat(1, Date.today) %>
and
<% @seatOne.each do |s1| %>
These can cause an issue with accidentally mistyping something. I hope this helps and I hope others read the absent issue.
@beisert1 I noticed that in your students#index view file, up at the top you have @absentStudents = Student.absent(Date.today)
, but at the bottom you use @students.each do |student|
for your loop, and in the controller you define students with @students = Student.all
.
I'm not sure why your students are being displayed in class, but might be why they're not disappearing from the absent section.
Thanks everyone im pretty sure I have it down now!
After logging attendance the student should be moved from absent to in class but I cant get that to show up correctly