[raleigh.rb] Find Query - Associations Help
Alfredo Quiroga-Villamil
lawwton at gmail.com
Tue Feb 3 12:20:20 EST 2009
All:
I am trying to create a query using rails and I am not quite sure how
to do it. I could get this done using plane old sql with no problem
and was even planning on doing that until I ran into a little issue
with find_by_sql. It seems that this does not preserve order.
What I need using Rails Active Record is the following:
I have a series of tables as follows:
tickets <habtm> users
tables here:
tickets
tickets_users
users
I also have:
users <habtm> roles
tables here:
users
roles_users
roles
What I need is a query where I can filter by roles. Essentially saying
... give me all the tickets for users whose role is 'foo'.
Thanks in advance,
Alfredo
More information about the raleigh-rb-members
mailing list