Class: Decidim::Devise::RegistrationsController

Inherits:
Devise::RegistrationsController
  • Object
show all
Includes:
Decidim::DeviseControllers, FormFactory, NeedsTosAccepted
Defined in:
app/controllers/decidim/devise/registrations_controller.rb

Overview

This controller customizes the behaviour of Devise’s RegistrationsController so we can specify a custom layout.

Instance Method Summary collapse

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/decidim/devise/registrations_controller.rb', line 23

def create
  @form = form(RegistrationForm).from_params(params[:user].merge(current_locale: current_locale))

  CreateRegistration.call(@form) do
    on(:ok) do |user|
      if user.active_for_authentication?
        set_flash_message! :notice, :signed_up
        (:user, user)
        respond_with user, location: (user)
      else
        set_flash_message! :notice, :"signed_up_but_#{user.inactive_message}"
        expire_data_after_sign_in!
        respond_with user, location: (user)
      end
    end

    on(:invalid) do
      flash.now[:alert] = @form.errors[:base].join(", ") if @form.errors[:base].any?
      render :new
    end
  end
end

#newObject



17
18
19
20
21
# File 'app/controllers/decidim/devise/registrations_controller.rb', line 17

def new
  @form = form(RegistrationForm).from_params(
    user: { sign_up_as: "user" }
  )
end