From 047df46a976bbf756e2351c0df63494722245906 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 3 Sep 2011 18:26:16 +0800 Subject: [PATCH] Fixed bug where unwatched apps were being shown for non-admin users. Added extra comment to explain how InheritedResources' begin_of_association_chain works. --- app/controllers/apps_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index 781606d..3454cbc 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -46,7 +46,9 @@ class AppsController < InheritedResources::Base protected def collection # Sort apps by number of unresolved errs (highest number first) - @apps ||= App.all.sort{|a,b| b.errs.unresolved.count <=> a.errs.unresolved.count } + @apps ||= end_of_association_chain.all.sort{|a,b| + b.errs.unresolved.count <=> a.errs.unresolved.count + } end def initialize_subclassed_issue_tracker @@ -58,6 +60,8 @@ class AppsController < InheritedResources::Base end def begin_of_association_chain + # Filter the @apps collection to apps watched by the current user, unless user is an admin. + # If user is an admin, then no filter is applied, and all apps are shown. current_user unless current_user.admin? end -- libgit2 0.21.2