mardi 24 février 2015

How to get a list of active-record objects in an instance variable by looping through it with some condition?

I have an Exam model. I want to get all records that satisfy a condition in an instance variable.


I tried this in my controller:



@exam_list = Exam.all
@exams = []
@exam_list.each do |exam|
if conflict?([current_exam.exam_date, current_exam.end_date],[exam.exam_date, exam.end_date])
@exams << e
end
end


But its not working.


Aucun commentaire:

Enregistrer un commentaire