diff --git a/app/controllers/rb_application_controller.rb b/app/controllers/rb_application_controller.rb index 736e19cc8b..4006c03d9e 100644 --- a/app/controllers/rb_application_controller.rb +++ b/app/controllers/rb_application_controller.rb @@ -4,18 +4,16 @@ class RbApplicationController < ApplicationController helper :rb_common - before_filter :load_project, :authorize, :check_if_plugin_is_configured + before_filter :load_sprint_and_project, :authorize, :check_if_plugin_is_configured private # Loads the project to be used by the authorize filter to # determine if User.current has permission to invoke the method in question. - def load_project - if params[:sprint_id] - load_sprint_and_project - else - @project = Project.find(params[:project_id]) if params[:project_id] - end + def load_sprint_and_project + load_sprint_and_parent_project if params[:sprint_id] + # This overrides sprint's project if we set another project, say a subproject + @project = Project.find(params[:project_id]) if params[:project_id] end def check_if_plugin_is_configured @@ -27,8 +25,8 @@ class RbApplicationController < ApplicationController end end - def load_sprint_and_project(id = params[:sprint_id].to_i) - @sprint = Sprint.find(id) + def load_sprint_and_parent_project + @sprint = Sprint.find(params[:sprint_id]) @project = @sprint.project end end