Harsha M V
Harsha M V

Reputation: 54949

Rails Devise check if User has not Logged in

I am trying to check if the user session is not active

<% if user_signed_in?! %>
        <div class="homeActions">
          <%= link_to "Become a Host", new_host_path, class: "btn btn-lg btn-success" %>
        </div>
        <% end %>

Upvotes: 2

Views: 3211

Answers (1)

Joe Kennedy
Joe Kennedy

Reputation: 9443

You can use

<% if !user_signed_in? %>

or

<% if not user_signed_in? %>

or

<% unless user_signed_in? %>

! and not negate the preceding boolean expression, while unless is the exact opposite of if.

Upvotes: 8

Related Questions