Ruby-on-rails – Use current_user in application controller

deviseruby-on-rails

I use devise for authentication. In my User model there is a field "locale", which I want to use in the application controller for the current logged in user. So I have this in the application controller:

    @user = User.current_user.locale

But this doesn't work. How can I access fields of the current user in the application controller? And devise hasn't created a users controller, where can I find that when I want to make some changes there? Thanks!

Best Answer

current_user is already User object, just call locale on it :

@user = current_user
locale = current_user.locale