@ -119,12 +119,14 @@ class Project < ActiveRecord::Base
# ORDER BY "projects"."id" ASC LIMIT 1
# this results in the following genre of errors on PostgreSQL:
# …it is not contained in either an aggregate function or the GROUP BY clause
default_scopeorder('')
scope:has_module,lambda{|mod|{conditions:["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)",mod.to_s]}}
{conditions:["#{User.table_name}.id IN (SELECT gu.user_id FROM #{table_name_prefix}group_users#{table_name_suffix} gu WHERE gu.group_id = ?)",group_id]}
where(["#{User.table_name}.id IN (SELECT gu.user_id FROM #{table_name_prefix}group_users#{table_name_suffix} gu WHERE gu.group_id = ?)",group_id])
}
scope:not_in_group,lambda{|group|
scope:not_in_group,->(group){
group_id=group.is_a?(Group)?group.id:group.to_i
{conditions:["#{User.table_name}.id NOT IN (SELECT gu.user_id FROM #{table_name_prefix}group_users#{table_name_suffix} gu WHERE gu.group_id = ?)",group_id]}
where(["#{User.table_name}.id NOT IN (SELECT gu.user_id FROM #{table_name_prefix}group_users#{table_name_suffix} gu WHERE gu.group_id = ?)",group_id])