class UsersController

Public Instance Methods

create() click to toggle source

POST /users

# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 42
def create
  create_user_params = params.require(:user).permit!
  if @user.register(create_user_params)
    redirect_to new_user_path, notice: t('hello.business.registration.sign_up.success')
  else
    render action: :new
  end
end
impersonate() click to toggle source

POST /users/1/impersonate

# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 52
def impersonate
  sign_in!(@user, 60.minutes.from_now, 60.minutes.from_now)

  redirect_to root_path, notice: t('hello.business.authentication.sign_in.success')
end
index() click to toggle source

GET /users

# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 11
def index
  @users = User.order(:id)
  @count = User.count
end
list() click to toggle source

GET /users/list

# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 32
def list
  @users = User.order(:id)
  @count = User.count
end
new() click to toggle source

GET /users/new

# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 38
def new
end
show() click to toggle source

GET /users/username GET /users/id -> redirects to /users/username

# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 18
def show
end

Private Instance Methods

find_user() click to toggle source
# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 60
def find_user
  @user = User.find_by_username!(params[:id])
rescue ActiveRecord::RecordNotFound
  redirect_to User.find_by_id!(params[:id]) # forces redirect to path with username if used id on URL
end
init_user() click to toggle source
# File lib/generators/hello/users/templates/app/controllers/users_controller.rb, line 66
def init_user
  @user = Hello::ClassicSignUpEntity.new
end