I am trying to add the header to my rails application based on authenticating the user. So here I am checking that if the user has logged in or signed in and then adding login/logout link based on that.
But I am getting the following error:
application.html.erb:16: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' ...roy_user_session_path, method :delete );@output_buffer.safe_
Here's what I have tried:
<% if user_signed_in? do %>
<%= link_to "Log out", destroy_user_session_path, method :delete %>
<% else %>
<%= link_to "login", new_user_session_path %>
<% end %>
How can I resolve this?
First of all remove do
from this line, you don't need that
<% if user_signed_in? %>
Secondly add :
after method
, it's a key value pair
<%= link_to "Log out", destroy_user_session_path, method: :delete %>
Hope that helps!