From 1a917bc954f7e2b0c7233288c73476f572cad8d6 Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Thu, 24 Jan 2013 03:18:07 +0400 Subject: [PATCH] fix scope to empty relation --- app/models/user_team.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user_team.rb b/app/models/user_team.rb index 0442123fc24..e3037bcd1aa 100644 --- a/app/models/user_team.rb +++ b/app/models/user_team.rb @@ -17,7 +17,7 @@ class UserTeam < ActiveRecord::Base scope :with_member, ->(user){ joins(:user_team_user_relationships).where(user_team_user_relationships: {user_id: user.id}) } scope :with_project, ->(project){ joins(:user_team_project_relationships).where(user_team_project_relationships: {project_id: project})} - scope :without_project, ->(project){ where("id NOT IN (:ids)", ids: with_project(project))} + scope :without_project, ->(project){ where("id NOT IN (:ids)", ids: (a = with_project(project); a.blank? ? 0 : a))} scope :created_by, ->(user){ where(owner_id: user) } class << self