Files
openfoodnetwork/app/controllers/locales_controller.rb
Jean-Baptiste Bellet aa982fe8df Create a new method to change the lang of the app
- The old method (link to `?locale=#{l.to_s}`) was not functional for path that already has query params in current path (such as `/user/spree_user/password/edit?reset_password_token=`) ;
 - This seems that the best way to handle this, is to create a new route, new method that effectively set the lang (not the locale actually...) and then redirect_back (ie. using the HTTP_REFERER, with a fallback to `/`)

s
2021-07-06 10:09:37 +02:00

9 lines
226 B
Ruby

# frozen_string_literal: true
class LocalesController < BaseController
def show
UserLocaleSetter.new(spree_current_user, params[:id], cookies).set_locale
redirect_back fallback_location: main_app.root_url
end
end