Hey all, I get a sitenum undefined method error. Problem is I am trying to target site_id and student_number and then increment value of student_number by 1 based on site_id. So there will be at least two records with a 2001 value for student_number if there are two site_ids (e.g. site_id 1, site_id 2). And if a value of 2001 exists for that site, then I would like to increment by 1 so next student_number for that site will be 2002, 2003, etc.
Student Model:
:student_number =>
sitenum = self.site_id
count = Student.count_by_sql("SELECT MAX(student_number) FROM students WHERE site_id = #{sitenum}")
if count >= 2001
Student.sitenum(:order => "student_number DESC").student_number + 1
else
2001
end
Any response would be greatly appreciated.