how to create users_controller.rb with devise?

dongdongxiao

I used gem: devise to create models/user.rb by running rails g devise User, and I used devise to create views by running rails g devise:views. Now I want to create controllers/users_controller.rb. How can I do that?

rails g controller users

Is this correct? And is this user connected with devise User? I looked at another app, and class UsersController < ApplicationController works there.

I am new. Thanks for answering.

Deep

You can generate the devise controllers using its generate command:

rails generate devise:controllers [scope]

The scope means which folder you want to create it, like if it is for users then you can give users as scope which will generate the controller in app/controllers/users/.

You will need to specify this in routes so that rails uses your controllers:

devise_for :users, controllers: { registrations: "users/registrations" }

If you need a controller named users_controller then you can generate it using:

rails g controller users

But it will not connect with devise. All the actions (new, create, update, edit) of User are handled in registrations_controller by devise. So you can always override them if that is what required by you. So it will call your custom code instead of the default code.

If you create your own users_controller it will be normal rails controller. Just define routes for it and create the views inside the users folder it will work.

More info you can find in devise wiki:

https://github.com/plataformatec/devise#configuring-controllers

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to create users_controller.rb with devise?

From Dev

How devise methods are available in ApplicationController.rb?

From Dev

How to create new devise user using foreign controller

From Dev

How to create new devise user using foreign controller

From Dev

Devise: Create users without password

From Dev

How to create seeds.rb array?

From Dev

Devise/CanCanCan - Allow Admin To Create New Users

From Dev

Rails problems posting to users_controller action

From Dev

devise_for: How should we do so that only admin can create normal users?

From Dev

devise_for: How should we do so that only admin can create normal users?

From Dev

how to create a model after a devise registration

From Dev

How to use devise parent_controller for devise inherited controller but skip for ActiveAdmin devise controller?

From Dev

how to access the devise @user instance variable outside of the devise controller & templates

From Dev

How to create a variable in env.rb or hook.rb and call in cucumber feature ?

From Dev

how to make admin users using devise and cancan?

From Dev

how to add users after signing in in devise gem?

From Dev

How to let users ping admins rails devise

From Dev

Ruby Motion, Rails 3.x, Devise login through custom api/v1/sessions_controller.rb

From Dev

Rails 4 - Devise 3 not working (NoMethodError in Users::RegistrationController#create )

From Dev

Can't get users to create a custom message with devise invitable

From Dev

How to generate Registration controller of devise gem

From Dev

How to solve argument error in Devise Registrations controller?

From Dev

Ruby on Rails: Custom Devise Registration Controller, Asking For Create Action

From Dev

Create user in other controller and view (Rails 4 with Devise)

From Dev

How to create fixtures (for a Devise user) as a yml.erb in rails (4.1.5)?

From Dev

How do I pass a block to the Devise create method?

From Dev

How to create a link that automatically logs the user in on devise / rails?

From Dev

How create and include Profile in User model (User its model devise)?

From Dev

How create and include Profile in User model (User its model devise)?

Related Related

  1. 1

    how to create users_controller.rb with devise?

  2. 2

    How devise methods are available in ApplicationController.rb?

  3. 3

    How to create new devise user using foreign controller

  4. 4

    How to create new devise user using foreign controller

  5. 5

    Devise: Create users without password

  6. 6

    How to create seeds.rb array?

  7. 7

    Devise/CanCanCan - Allow Admin To Create New Users

  8. 8

    Rails problems posting to users_controller action

  9. 9

    devise_for: How should we do so that only admin can create normal users?

  10. 10

    devise_for: How should we do so that only admin can create normal users?

  11. 11

    how to create a model after a devise registration

  12. 12

    How to use devise parent_controller for devise inherited controller but skip for ActiveAdmin devise controller?

  13. 13

    how to access the devise @user instance variable outside of the devise controller & templates

  14. 14

    How to create a variable in env.rb or hook.rb and call in cucumber feature ?

  15. 15

    how to make admin users using devise and cancan?

  16. 16

    how to add users after signing in in devise gem?

  17. 17

    How to let users ping admins rails devise

  18. 18

    Ruby Motion, Rails 3.x, Devise login through custom api/v1/sessions_controller.rb

  19. 19

    Rails 4 - Devise 3 not working (NoMethodError in Users::RegistrationController#create )

  20. 20

    Can't get users to create a custom message with devise invitable

  21. 21

    How to generate Registration controller of devise gem

  22. 22

    How to solve argument error in Devise Registrations controller?

  23. 23

    Ruby on Rails: Custom Devise Registration Controller, Asking For Create Action

  24. 24

    Create user in other controller and view (Rails 4 with Devise)

  25. 25

    How to create fixtures (for a Devise user) as a yml.erb in rails (4.1.5)?

  26. 26

    How do I pass a block to the Devise create method?

  27. 27

    How to create a link that automatically logs the user in on devise / rails?

  28. 28

    How create and include Profile in User model (User its model devise)?

  29. 29

    How create and include Profile in User model (User its model devise)?

HotTag

Archive