Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current_user method using devise

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 ?

like image 864
Danny Connolly Avatar asked Jan 25 '12 13:01

Danny Connolly


People also ask

How does devise current_user work?

current_user works by storing id of current user in the application session. Most commonly session is stored in cookies. Whether or not the cookies survive browser restart depends on client's browser settings.

How do I get a current user in devise?

1 Answer. Show activity on this post. If user is not logged in, i.e., current_user=nil then user would be redirected to login page with a flash message.

What is current_user?

The CURRENT_USER() function returns the user name and host name for the MySQL account that the server used to authenticate the current client. The result is returned as a string in the UTF8 character set.

What is devise in Ruby?

Devise is the cornerstone gem for Ruby on Rails authentication. With Devise, creating a User that can log in and out of your application is so simple because Devise takes care of all the controllers necessary for user creation ( users_controller ) and for user sessions ( users_sessions_controller ).


1 Answers

Devise creates that helper method for you, and others too. Check

https://github.com/heartcombo/devise#controller-filters-and-helpers

like image 89
Nicolas Garnil Avatar answered Oct 18 '22 10:10

Nicolas Garnil