Sha256: 38d283776540216c8524a881fcf42b52c066f67cd762f3409efec6c7621501e2

Contents?: true

Size: 603 Bytes

Versions: 2

Compression:

Stored size: 603 Bytes

Contents

require_dependency "whodat/application_controller"

module Whodat
  class UsersController < ApplicationController
    def new
      @user = User.new
    end

    def create

      @user = User.new(user_params)
      
      if @user.save
        flash[:notice] = "Welcome, #{@user.name}!"
        create_session(@user)
        redirect_to main_app.root_path
      else
        flash[:notice] = "An error occurred. Please try again."
        render :new
      end
    end

private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whodat-1.0.1 app/controllers/whodat/users_controller.rb
whodat-1.0.0 app/controllers/whodat/users_controller.rb