diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 55afb7b2..99f108ce 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -16,6 +16,7 @@ class HomeController < ApplicationController def update_profile if @current_user.update_attributes(params[:user]) + session[:locale] = @current_user.locale redirect_to my_profile_url, notice: I18n.t('home.changes_saved') else render :profile diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 745d5e58..3aab74c5 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -58,6 +58,7 @@ class LoginController < ApplicationController if @user.save Membership.new(:user => @user, :group => @invite.group).save! @invite.destroy + session[:locale] = @user.locale redirect_to login_url, notice: I18n.t('login.controller.accept_invitation.notice') end end diff --git a/app/models/user.rb b/app/models/user.rb index 0a5767b6..aced06d7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -57,6 +57,10 @@ class User < ActiveRecord::Base end end + def locale + settings.profile['language'] + end + def name [first_name, last_name].join(" ") end diff --git a/lib/foodsoft/controller_extensions.rb b/lib/foodsoft/controller_extensions.rb index a5f3fe6f..e0b64aa6 100644 --- a/lib/foodsoft/controller_extensions.rb +++ b/lib/foodsoft/controller_extensions.rb @@ -13,7 +13,7 @@ module Foodsoft end def user_settings_language - current_user.settings.profile['language'] if current_user + current_user.locale if current_user end def session_language