Commit 047df46a976bbf756e2351c0df63494722245906

Authored by Nathan Broadbent
1 parent 9883381f
Exists in master and in 1 other branch production

Fixed bug where unwatched apps were being shown for non-admin users. Added extra…

… comment to explain how InheritedResources' begin_of_association_chain works.
Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
app/controllers/apps_controller.rb
... ... @@ -46,7 +46,9 @@ class AppsController < InheritedResources::Base
46 46 protected
47 47 def collection
48 48 # Sort apps by number of unresolved errs (highest number first)
49   - @apps ||= App.all.sort{|a,b| b.errs.unresolved.count <=> a.errs.unresolved.count }
  49 + @apps ||= end_of_association_chain.all.sort{|a,b|
  50 + b.errs.unresolved.count <=> a.errs.unresolved.count
  51 + }
50 52 end
51 53  
52 54 def initialize_subclassed_issue_tracker
... ... @@ -58,6 +60,8 @@ class AppsController &lt; InheritedResources::Base
58 60 end
59 61  
60 62 def begin_of_association_chain
  63 + # Filter the @apps collection to apps watched by the current user, unless user is an admin.
  64 + # If user is an admin, then no filter is applied, and all apps are shown.
61 65 current_user unless current_user.admin?
62 66 end
63 67  
... ...