Need help with (simple?) find statement

I have a basic enrollment system where a user can enroll in a course
either as a student or instructor.

users(login)
enrollments(user_id, course_id, type_user_id)
courses(title)
type_users(title) where title is ‘instructor’ or ‘student’

I need to list all the courses for which a user is the instructor so I
wrote this

user.courses.find(:all, :include => {:enrollments => :type_user},
:conditions => “type_users.title =
‘instructor’”)

What this is returning, however, is all the courses the user is
enrolled in that has an instructor. Thanks for any help!

vince wrote:

user.courses.find(:all, :include => {:enrollments => :type_user},
:conditions => “type_users.title =
‘instructor’”)

What this is returning, however, is all the courses the user is
enrolled in that has an instructor. Thanks for any help!

What does your SELECT statement look like?


Michael W.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs