I have a model students. in studentsController I select a collection of students. I want to attach a flag to the first and the last record.
I'll display the list of students with a partial like this: students/_student and when a user clicks each student, they'll get a popup.
I want to use the flag to determine whether this student is the first/last so that I can add a query parameter to the url. So for instance, the url will look like this when you hover over the first student: localhost:3000/student/1?location=first
When displaying though a partial, the collection is not present in the partial, and so I cannot just do a test like this: student.first?
Any ideas? Thank you.
[EDIT]. This was originally a reply to @neils, but I figured I'd put it out there: It works however I have another issue. Because I'm using an "auto-scroll" feature, which loads in more students as the user scrolls down the page ( 3 at a time), the "first" and "last" gets added to the first and third student of each row rather than the actual first and last of the collection. The way I do the auto-scroll: I use $.getScript to request the index.js.erb file. That file renders the students/_student like so: render @students, and attach to a container div. I render the url in that template (students/_student), so the params gets rendered every first/third time.