From 43deb0f5ff8e1231c72f9513b148178b06163ce7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Thu, 7 Oct 2021 17:43:32 +0200
Subject: [PATCH] sign up: language

---
 app/controllers/users/registrations_controller.rb | 6 ++++++
 app/views/devise/registrations/new.html.erb       | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
index e21fd7e87..0fd4b4e0b 100644
--- a/app/controllers/users/registrations_controller.rb
+++ b/app/controllers/users/registrations_controller.rb
@@ -1,5 +1,6 @@
 class Users::RegistrationsController < Devise::RegistrationsController
   prepend_before_action :set_university, only: :create
+  before_action :configure_sign_up_params, only: :create
 
   protected
 
@@ -7,4 +8,9 @@ class Users::RegistrationsController < Devise::RegistrationsController
     return if request.params[:user].nil?
     request.params[:user][:university_id] = current_university.id
   end
+
+  # If you have extra params to permit, append them to the sanitizer.
+  def configure_sign_up_params
+    devise_parameter_sanitizer.permit(:sign_up, keys: [:language_id])
+  end
 end
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
index cf520eccd..4fab283ac 100644
--- a/app/views/devise/registrations/new.html.erb
+++ b/app/views/devise/registrations/new.html.erb
@@ -15,6 +15,9 @@
     <%= f.input :password_confirmation,
                 required: true,
                 input_html: { autocomplete: "new-password" } %>
+    <%= f.association :language,
+                      required: true,
+                      include_blank: 'Select a language' %>
   </div>
 
   <div class="form-actions">
-- 
GitLab