Skip to content

Commit

Permalink
add registration form
Browse files Browse the repository at this point in the history
  • Loading branch information
usernaimandrey committed Nov 10, 2023
1 parent 3619f04 commit f390f19
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/controllers/web/devise/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ class Web::Devise::RegistrationsController < Devise::RegistrationsController
include GonInit
include LocaleConcern

protected

def build_resource(hash = {})
self.resource = Web::UserRegistrationForm.new_with_session(hash, session)
end

private

def check_captcha
Expand Down
14 changes: 14 additions & 0 deletions app/forms/web/user_registration_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

class Web::UserRegistrationForm < User
include ActiveFormModel

validates :first_name, :last_name, :email, :password, :password_confirmation, presence: true
validates :email, 'valid_email_2/email': true

fields :first_name,
:last_name,
:email,
:password,
:password_confirmation
end
6 changes: 3 additions & 3 deletions app/views/devise/registrations/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ h2
= f.error_notification message: t('devise.correct_errors')
.form-inputs
.mb-3
= f.input :last_name, required: true, autofocus: true
= f.input :last_name, autofocus: true
.mb-3
= f.input :first_name, required: true
= f.input :first_name
.mb-3
= f.input :email, required: true, input_html: { autocomplete: 'email' }
= f.input :email, input_html: { autocomplete: 'email' }
.mb-3
= f.input :password, required: true,
hint: (t('devise.shared.minimum_password_length', count: @minimum_password_length) if @minimum_password_length),
Expand Down

0 comments on commit f390f19

Please sign in to comment.