From b008f876845e1ac9a16d4db838c9a2303327042b Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sat, 15 Aug 2015 07:14:49 +0300 Subject: [PATCH] Store the locale upon user registration --- app/controllers/registrations_controller.rb | 25 +++++++++++++++++++++ config/routes.rb | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 app/controllers/registrations_controller.rb diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb new file mode 100644 index 0000000..5789a68 --- /dev/null +++ b/app/controllers/registrations_controller.rb @@ -0,0 +1,25 @@ +class RegistrationsController < Devise::RegistrationsController + def create + build_resource(sign_up_params) + + resource.language = I18n.locale + + resource.save + yield resource if block_given? + if resource.persisted? + if resource.active_for_authentication? + set_flash_message :notice, :signed_up if is_flashing_format? + sign_up(resource_name, resource) + respond_with resource, location: after_sign_up_path_for(resource) + else + set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format? + expire_data_after_sign_in! + respond_with resource, location: after_inactive_sign_up_path_for(resource) + end + else + clean_up_passwords resource + set_minimum_password_length + respond_with resource + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 4e6d5b1..f800744 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - devise_for :users + devise_for :users, controllers: {registrations: 'registrations'} scope module: :public do root to: 'home#index'