avoid trying to change a user's locale while in a slave-query block

test plan: visit a canvas course as a new user who has their browser set
to a non-en locale. you shouldn't see a page error.

Change-Id: I5f0447faaec4971a08082de9819d9be79f19935f
Reviewed-on: https://gerrit.instructure.com/13062
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
Brian Palmer 2012-08-21 12:07:38 -06:00
parent 99c5a21022
commit 23710712fb
1 changed files with 3 additions and 1 deletions

View File

@ -2545,10 +2545,12 @@ class Course < ActiveRecord::Base
end
def tabs_available(user=nil, opts={})
# make sure t() is called before we switch to the slave, in case we update the user's selected locale in the process
default_tabs = Course.default_tabs
ActiveRecord::Base::ConnectionSpecification.with_environment(:slave) do
# We will by default show everything in default_tabs, unless the teacher has configured otherwise.
tabs = self.tab_configuration.compact
default_tabs = Course.default_tabs
settings_tab = default_tabs[-1]
external_tabs = external_tool_tabs(opts)
tabs = tabs.map do |tab|