Sha256: 6547fb6984074898861ee8d08a22861afc59a3f2fafa810b0b928805938d18c3

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

class RegistrationsController < ApplicationController
  skip_before_action :authenticate

  def new
    @<%= singular_table_name %> = <%= class_name %>.new
  end

  def create
    @<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)

    if @<%= singular_table_name %>.save
      @session = @user.sessions.create!(session_params)
      cookies.signed.permanent[:session_token] = { value: @session.id, httponly: true }

      redirect_to root_path, notice: "Welcome! You have signed up successfully"
    else
      render :new, status: :unprocessable_entity
    end
  end

  private
    def <%= "#{singular_table_name}_params" %>
      params.require(:<%= singular_table_name %>).permit(:email, :password, :password_confirmation)
    end

    def session_params
      { user_agent: request.user_agent, ip_address: request.remote_ip }
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authentication-zero-2.0.0 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt