diff --git a/app/models/project.rb b/app/models/project.rb index 262ca9f5..176c731f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -73,6 +73,7 @@ class Project < ActiveRecord::Base scope :public_only, where(private_flag: false) scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } + scope :authorized_for, ->(user) { joins(:users_projects) { where(user_id: user.id) } } class << self def active diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index a15396aa..8f667420 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -17,4 +17,4 @@ → %span.last_activity %strong Projects: - %span= group.projects.count + %span= group.projects.authorized_for(current_user).count