search for: find_users_in_group_with_titl

Displaying 1 result from an estimated 1 matches for "find_users_in_group_with_titl".

2006 Apr 12
0
Looking for a simpler model using :through associations
...ole end A typical use case is to find the owner of a given group, or more generally, find users with a given title in a given group. This can be done roughly like: class Group < ActiveRecord::Base has_many :roles, :dependent => :destroy has_many :users, :through => :roles def find_users_in_group_with_title(title) User.find_by_sql([ "SELECT users.* from users, roles, titles, groups "+ "WHERE users.id = roles.user_id "+ "AND groups.id = roles.group_id "+ "AND titles.id = roles.title_id "+ "AND titles.name = ? "+ "AND groups.id...