You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have code(app/controllers/application_controller.rb) like this:
# Set application local language by current logged user, else with :'zh-CN' as default locale
def set_locale
# [1] pry(#<HomeController>)> current_user
# TypeError: [1] is not a symbol
# Correct:
# "warden.user.user.key"=>["User", [1], "$2a$10$O46IZlHkrI5SOv3r.Ftci."]
# Error one:
# "warden.user.user.key"=>[[1], "$2a$10$UjRcTEy8j4FYICBFvf2qyu"]
if (current_user rescue (session['warden.user.user.key']=nil; false))
I18n.locale = current_user.application_locale
else
I18n.locale = ServerProfile.current_profile.default_application_locale rescue :'zh-CN'
end
end
After I invoke rubocop -a, it changed my code like this:
# Set application local language by current logged user, else with :'zh-CN' as default locale
def set_locale
# [1] pry(#<HomeController>)> current_user
# TypeError: [1] is not a symbol
# Correct:
# "warden.user.user.key"=>["User", [1], "$2a$10$O46IZlHkrI5SOv3r.Ftci."]
# Error one:
# "warden.user.user.key"=>[[1], "$2a$10$UjRcTEy8j4FYICBFvf2qyu"]
if current_user rescue (session['warden.user.user.key'] = nil; false)
I18n.locale = current_user.application_locale
else
I18n.locale = ServerProfile.current_profile.default_application_locale rescue :'zh-CN'
end
end
Error log is:
/Users/qichunren/code/work/luna-server/app/controllers/application_controller.rb:147: syntax error, unexpected modifier_rescue, expecting keyword_then or ';' or '\n'
if current_user rescue (session['warden.user.user.k...
^
/Users/qichunren/code/work/luna-server/app/controllers/application_controller.rb:179: syntax error, unexpected keyword_end, expecting $end
The text was updated successfully, but these errors were encountered:
My ENV:
I have code(app/controllers/application_controller.rb) like this:
After I invoke
rubocop -a
, it changed my code like this:Error log is:
The text was updated successfully, but these errors were encountered: