diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3dc319ea0..a926fae52 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -83,7 +83,7 @@ class ApplicationController < ActionController::Base private def update_current_team - current_team = Team.find_by_id(current_user.current_team_id) + @current_team = Team.find_by_id(current_user.current_team_id) if (current_team.nil? || !current_user.is_member_of_team?(current_team)) && current_user.teams.count.positive? diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9a6c6682c..73dc1f083 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -4,6 +4,7 @@ class ProjectsController < ApplicationController include TeamsHelper include InputSanitizeHelper + before_action :switch_team_with_param, only: :index before_action :load_vars, only: %i(show edit update notifications reports samples experiment_archive @@ -37,7 +38,6 @@ class ProjectsController < ApplicationController } end format.html do - current_team_switch(Team.find_by_id(params[:team])) if params[:team] @teams = current_user.teams # New project for create new project modal @project = Project.new diff --git a/app/helpers/teams_helper.rb b/app/helpers/teams_helper.rb index 9c5d116bb..87c8d0ffe 100644 --- a/app/helpers/teams_helper.rb +++ b/app/helpers/teams_helper.rb @@ -4,6 +4,7 @@ module TeamsHelper if team != current_team current_user.current_team_id = team.id current_user.save + update_current_team end end