A nice set of view helper in Rails link_to_if and link_to_unless. These helpers allow you to conditionally render a link. They also provide a nice way of showing different links based on the conditional.

For example you can show a β€œLogout” link if the user has signed in or the β€œLogin” link (inside of the block) if they have not yet signed in.

<%= link_to_if user_signed_in?, "Logout", destroy_user_session_path, method: :delete do %>
  <%= link_to "Login", new_user_session_path %>
<% end %>