Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UsersController
- Defined in:
- lib/generators/hello/users/templates/app/controllers/users_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /users.
-
#impersonate ⇒ Object
POST /users/1/impersonate.
-
#index ⇒ Object
GET /users.
-
#list ⇒ Object
GET /users/list.
-
#new ⇒ Object
GET /users/new.
-
#show ⇒ Object
GET /users/username GET /users/id -> redirects to /users/username.
Instance Method Details
#create ⇒ Object
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 |
#impersonate ⇒ Object
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 |
#index ⇒ Object
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 |
#list ⇒ Object
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 |
#new ⇒ Object
GET /users/new
38 39 |
# File 'lib/generators/hello/users/templates/app/controllers/users_controller.rb', line 38 def new end |
#show ⇒ Object
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 |