summaryrefslogtreecommitdiff
path: root/app/controllers/registrations_controller.rb
blob: e5c5d51932106304185793bdb6f18e27a6c8acea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class RegistrationsController < ApplicationController
  skip_before_action :authenticate!

  def new
    @user = User.new
  end

  def create
    User.create!(user_params)
    redirect_to new_session_path
  rescue ActiveRecord::RecordInvalid => error
    redirect_to new_registration_path, error: error.record.errors
  end

  private

  def user_params
    params.require(:user).permit(:email, :password, :password_confirmation)
  end
end