Allow setting default locale in user settings migration.
Use DEFAULT_LOCALE=de to have german enabled for all users.
This commit is contained in:
parent
4ea940e4a3
commit
c7cdcf2b82
1 changed files with 9 additions and 0 deletions
|
@ -1,6 +1,13 @@
|
|||
class MigrateUserSettings < ActiveRecord::Migration
|
||||
def up
|
||||
say_with_time 'Save old user settings in new RailsSettings module' do
|
||||
|
||||
# Allow setting default locale via env parameter
|
||||
# This is used, when setting users language settings
|
||||
default_locale = I18n.default_locale
|
||||
tmp_locale = ENV['DEFAULT_LOCALE'].present? ? ENV['DEFAULT_LOCALE'].to_sym : default_locale
|
||||
I18n.default_locale = tmp_locale
|
||||
|
||||
old_settings = ConfigurableSetting.all
|
||||
|
||||
old_settings.each do |old_setting|
|
||||
|
@ -33,6 +40,8 @@ class MigrateUserSettings < ActiveRecord::Migration
|
|||
# save the user to apply after_save callback
|
||||
user.save
|
||||
end
|
||||
|
||||
I18n.default_locale = default_locale
|
||||
end
|
||||
|
||||
drop_table :configurable_settings
|
||||
|
|
Loading…
Reference in a new issue