Commit 1a917bc954f7e2b0c7233288c73476f572cad8d6
Committed by
Dmitriy Zaporozhets
1 parent
2befa8fe
Exists in
master
and in
4 other branches
fix scope to empty relation
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
app/models/user_team.rb
... | ... | @@ -17,7 +17,7 @@ class UserTeam < ActiveRecord::Base |
17 | 17 | |
18 | 18 | scope :with_member, ->(user){ joins(:user_team_user_relationships).where(user_team_user_relationships: {user_id: user.id}) } |
19 | 19 | scope :with_project, ->(project){ joins(:user_team_project_relationships).where(user_team_project_relationships: {project_id: project})} |
20 | - scope :without_project, ->(project){ where("id NOT IN (:ids)", ids: with_project(project))} | |
20 | + scope :without_project, ->(project){ where("id NOT IN (:ids)", ids: (a = with_project(project); a.blank? ? 0 : a))} | |
21 | 21 | scope :created_by, ->(user){ where(owner_id: user) } |
22 | 22 | |
23 | 23 | class << self | ... | ... |