Class: RegistrationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/active_registration/templates/registrations_controller.rb

Instance Method Summary collapse

Instance Method Details

#confirmObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/active_registration/templates/registrations_controller.rb', line 16

def confirm
  @user = User.find_by(confirmation_token: params[:token])

  if @user&.confirmation_period_valid?
    @user.confirm!
    redirect_to root_path, notice: "Email confirmed!"
  else
    redirect_to root_path, alert: "Invalid or expired confirmation link"
  end
end

#createObject



6
7
8
9
10
11
12
13
14
# File 'lib/generators/active_registration/templates/registrations_controller.rb', line 6

def create
  @user = User.new(user_params)
  if @user.save
    ConfirmationMailer.confirmation_instructions(@user).deliver_later
    redirect_to root_path, notice: "Confirmation email sent!"
  else
    render :new
  end
end

#newObject



2
3
4
# File 'lib/generators/active_registration/templates/registrations_controller.rb', line 2

def new
  @user = User.new
end