Current_user method using devise - ruby-on-rails

I've just started to use devise today and I want to know if I have to create a current user method in my application controller or is it already created through devise ?

Devise creates that helper method for you, and others too. Check
https://github.com/heartcombo/devise#controller-filters-and-helpers

Related

Accessing current_user devise method from rails controller

I'm using devise in a rails app I'm building. I'd like to get the ID of the user that is currently signed in, with current_user.id, in my controller, without passing it as a parameter from my view. Is there any way I can do this? Thanks
If you have installed Devise properly and have not broken something by overriding the Devise controllers, you should be able to access current_user.id from the controller. This method will only work if a user is signed in which you can test with the user_signed_in? method. Finally, this assumes that the resource name Devise is using is indeed user. That is the default, but it is possible to configure Devise to work with different resource names.

how to get twice path in devise routes?

i want to make twice url for login devise, first i want the url become to
"/user/sign_in"
and other become to
"/admin/sign_in"
how do this in devise rails?
thank you before
rails generate devise User
rails generate devise Admin
will create different views and routes for each MODEL

Devise 3.2.1custom redirect_to on Sign Up.

I am working with Rails 4.0.1 and Devise 3.2.1. After a user signs up I want to save their email address to the database. I then want to ask the user for additional information in the update action on a separate page.
How to I customer Devise's create action so that I redirect the user to the user/update controller action?
Thank you.
You could use after_sign_up_path_for in a newly-created RegistrationsController to control where the user goes after they sign up.
The devise documentation has a wiki article on how to do just this.

Devise will not let me register a user while logged in

I'm using devise for the user system but I have one problem. I'd like for a logged-in user to register new user. It's a question of security. However, a logged-in user can not currently register a new user.
I dont know how fix this.
Thanks by help!
I'm pretty sure the easist way would be just to turn off the devise config option :registerable, this will get rid of the sign_up paths and links.
Then just build your own user controller actions and views to interact directly with your User model.
The default devise registrations controller wants to auto create a new session for the newly created user which is why it won't let logged in users create another user.
Hope this helps.
The Devise documentation explains how to do that kind of thing.
You don't need to over-ride anything in devise. Just treat it like any other namespaced resource.

Rails 3: Devise users_controller, where is it?

After I create a devise as Users, where is users_controllers.rb?
Devise doesn't create a controller along with your model, so you have to generate it yourself:
rails g controller Users
Note that Devise uses its own internal controllers for things like session management and registrations. You can extend these, if you need to, but it is not mandatory.

Resources