Rails: syntax error, unexpected keyword_ensure, expecting $end
14,665
Solution 1
there has an error in your code.
You have extra end
in your code before the else
starts.
Removing that may solve your problem...
Solution 2
Remove the <% end %>
just before the <% else %>
.
The code should be as follows:
<ul class = "nav pull-right">
<% if user_signed_in? %>
<li><%= link_to current_user.full_name, edit_user_registration_path %></li>
<li><%= link_to "Log Out", destroy_user_session_path, method: :delete %></li>
<% else %>
<li><%= link_to "Log In", new_user_session_path %></li>
<li><%= link_to "Sign Up", new_user_registration_path %></li>
<%end%>
</ul>
Solution 3
If you'd use HAML, this could be the cause:
- model_class = Products
.products-page
What will solve? Identation.
- model_class = Products
.products-page
Solution 4
In my case I forgot a do
in a loop:
<% @things.each |thing| %>
The correct format is:
<% @things.each do |thing| %>
Author by
Kishore Eechambadi
Updated on June 12, 2022Comments
-
Kishore Eechambadi almost 2 years
I'm creating a very basic rails app (learning tutorial) and can't understand why I'm getting this error. I've tried troubleshooting but to no avail.
My code:
<ul class = "nav pull-right"> <% if user_signed_in? %> <li><%= link_to current_user.full_name, edit_user_registration_path %></li> <li><%= link_to "Log Out", destroy_user_session_path, method: :delete %></li> <% end %> <% else %> <li><%= link_to "Log In", new_user_session_path %></li> <li><%= link_to "Sign Up", new_user_registration_path %></li> <%end%> </ul>
Everything was working fine, until I added the Else statement, but no idea what my error is - I'm sure it's a very minor syntax fix, but your help would be much appreciated.