L
L
lavezzi12015-08-13 13:03:42
Ruby on Rails
lavezzi1, 2015-08-13 13:03:42

Why does not work - if current_user?

Hello. You need to hide the link to edit the profile on the user's pages and display it only for the current_user. I use gem Devise.
I'm trying to do it like this:

- if current_user?
          = link_to "Settings", edit_user_registration_path
                - else

Mistake
undefined method `current_user?' for #<#<Class:0x007f5fee1940b0>:0x007f5fecea0800>

But how to ask it? To work just like
- if user_signed_in?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Vsk, 2015-08-13
@viktorvsk

Copy-paste the error
And you get the first link to the stackoverflow
Where does the method come from current_user?if you haven't defined it anywhere? Devise creates a method current_userand you can use it in the same way if current_user
Is it really easier to post a question on a toaster these days than to remove one character in the code?)
PS than user_signed_in? did not arrange it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question