简体   繁体   中英

Hide a link if user signed in with Devise

I want to make it so if the user is signed in (using Devise) the "sign up" button in the navbar is hidden.

I was able to use

<%= if user_signed_in? %> <%= link_to etc.. %>

but I can't seem to get the write code to hide a button. I know there must be an else statement as well.

example

<%- if user_signed_in? %>
  <li><%= link_to t('auth.sign_out'), destroy_user_session_path, method: 'delete' %></li>
<% else %>
  <li><%= link_to t('auth.sign_in'), new_user_session_path %></li>
  <li><%= link_to t('auth.sign_up'), new_user_registration_path %></li>
<% end %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM