hi,
I have to settle a database query problem, and I am a bit confused.
I have 4 tables:
-----------------
Members
Groups
Roles
Memberships: member_id, group_id, role_id
Messages: concerned_group_id, content

If a member is logged in the application, I would like to display the
messages, regarding the groups (if any) of which the member is admin.
(admin is a role)

I don't know what is the best way to do that, but:
First I can find all Memberships, where the member is admin:
admin_role_id = Role.find_by_name("admin").id
Membership.find(:all, :conditions => ['member_id = ? and role_id = ?',
member.id, admin_role_id])

Each from the found Memberships has a group_id
Then how can I find all the Messages, that concern the groups with these
group_id-s?

Thank you!
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to