@@ -48,20 +48,20 class Principal < ActiveRecord::Base | |||
|
48 | 48 | scope :member_of, lambda {|projects| |
|
49 | 49 | projects = [projects] unless projects.is_a?(Array) |
|
50 | 50 | if projects.empty? |
|
51 | {:conditions => "1=0"} | |
|
51 | where("1=0") | |
|
52 | 52 | else |
|
53 | 53 | ids = projects.map(&:id) |
|
54 |
|
|
|
54 | where("#{Principal.table_name}.status = 1 AND #{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids) | |
|
55 | 55 | end |
|
56 | 56 | } |
|
57 | 57 | # Principals that are not members of projects |
|
58 | 58 | scope :not_member_of, lambda {|projects| |
|
59 | 59 | projects = [projects] unless projects.is_a?(Array) |
|
60 | 60 | if projects.empty? |
|
61 | {:conditions => "1=0"} | |
|
61 | where("1=0") | |
|
62 | 62 | else |
|
63 | 63 | ids = projects.map(&:id) |
|
64 |
|
|
|
64 | where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids) | |
|
65 | 65 | end |
|
66 | 66 | } |
|
67 | 67 |
General Comments 0
You need to be logged in to leave comments.
Login now