Commit 34c2d8e82eec046bd73a2ed145210bdc83bbe90e

Authored by Alex Denisov
1 parent 15a72a3b

authorized_for scope added to project

app/models/project.rb
... ... @@ -73,6 +73,7 @@ class Project < ActiveRecord::Base
73 73 scope :public_only, where(private_flag: false)
74 74 scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
75 75 scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
  76 + scope :authorized_for, ->(user) { joins(:users_projects) { where(user_id: user.id) } }
76 77  
77 78 class << self
78 79 def active
... ...
app/views/dashboard/_groups.html.haml
... ... @@ -17,4 +17,4 @@
17 17 &rarr;
18 18 %span.last_activity
19 19 %strong Projects:
20   - %span= group.projects.count
  20 + %span= group.projects.authorized_for(current_user).count
... ...