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!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
vince wrote:> 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!What does your SELECT statement look like? -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---