Reputation: 311
Working on devise and was wondering what the difference are between
<% if current_user.present? %>
and
<% if user_signed_in? %>
Upvotes: 3
Views: 450
Reputation: 106982
No, there isn't really a difference.
Look at the meta-programmed implementation of user_signed_in?
:
def #{mapping}_signed_in?
!!current_#{mapping}
end
When authenticating against a User
model this resolves to:
def user_signed_in?
!!current_user
end
Note: !!current_user
returns true
if current_user
is nil
or false
. And that is exactly the same what present?
does.
Upvotes: 4