Routes, controllers, and intentions

I have the following tables: courses, students, and rosters. The
rosters table references the courses and students tables. With
default routes in place, to list the students in a course I would use:
http://localhost:3000/rosters/list

but this lists the rosters for all courses.

if I use http://localhost:3000/rosters/list/1

rails looks in the rosters table for entry with the id =1. How do I
tell it I want all the entries where course_id = 1?

With default routing in place, it would seem to me to be something on
the order of the following, given courses, students, and rosters:

course
has_many rosters
has_many students through rosters

student
has_many rosters
has_many courses through rosters

roster
belongs_to course
belongs_to student


You need to pass the course_id to the roster in a param, like:

http://localhost:3000/rosters?course_id=1

which would allow a roster to determine which course it was for, and
retrieve all the appropriate students.

def show
@rosters = Roster.find(:all, :conditions => [‘course_id = ?’,
params[:course_id]])
end

There are many other ways to organize and get at this information, such
as a partial for the course ‘show’ form, like
‘_course_students.html.erb’, which could just loop through the
@course.students collection to display the list of students.