Class: UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/hello/users/templates/app/controllers/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /users



42
43
44
45
46
47
48
49
# 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

#impersonateObject

POST /users/1/impersonate



52
53
54
55
56
# 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

#indexObject

GET /users



11
12
13
14
# File 'lib/generators/hello/users/templates/app/controllers/users_controller.rb', line 11

def index
  @users = User.order(:id)
  @count = User.count
end

#listObject

GET /users/list



32
33
34
35
# File 'lib/generators/hello/users/templates/app/controllers/users_controller.rb', line 32

def list
  @users = User.order(:id)
  @count = User.count
end

#newObject

GET /users/new



38
39
# File 'lib/generators/hello/users/templates/app/controllers/users_controller.rb', line 38

def new
end

#showObject

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



18
19
# File 'lib/generators/hello/users/templates/app/controllers/users_controller.rb', line 18

def show
end