Sha256: 5a11c79014826b380f7aba44d4d697b740d7a5ff89bae69264df1a7a3aa4c74a

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

class SignupController < ApplicationController
  respond_to :html, :json

  # Create a new Signup form model (found in app/forms/signup.rb)
  def new
    @signup = Signup.new
  end

  def create
    @signup = Signup.new(signup_params)

    if @signup.save
      login(@signup.user)
      respond_to do |format|
        format.json { head :no_content }
        format.html {
          redirect_to root_path
        }
      end
    else
      respond_to do |format|
        format.json { render json: { status: 'error', errors: @signup.errors }.to_json, status: 422 }
        format.html { render :new }
      end
    end
  end

  protected

  def signup_params
    params.require(:signup).permit(
      :email,
      :username,
      :password,
      :password_confirmation,
      :first_name,
      :last_name,
      :bio,
      :website,
      :phone_number,
      :time_zone)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authkit-0.2.1 lib/generators/authkit/templates/app/controllers/signup_controller.rb