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



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

def create
  @form = form(RegistrationForm).from_params(params[:user].merge(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] = t("error", scope: "decidim.devise.registrations.create")
      render :new
    end
  end
end

#newObject



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

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