Rails Syntax Error: Unexpected Keyword_Ensure, Expecting Keyword_End

Rails syntax error, unexpected keyword_ensure, expecting keyword_end

You are failing to close 2 of your loops with an <% end %>.

<% unless @artwork.series.blank? %>
<div class="col-xs-6 col-sm-6 col-md-4">
<p class="field-label">Series</p>
<% @artwork.series.each do |series| %>
<span class="tags">
<%= link_to series.name, series_url(:series => series.name) %>
</span>
<%# Need end here, as illustrated on the next line. %>
<% end %>
</div>
<% end %>

<% unless @artwork.tags.blank? %>
<div class="col-xs-6 col-sm-6 col-md-4">
<p class="field-label">Tags</p>
<% @artwork.tags.each do |tag| %>
<span class="tags">
<%= link_to tag.name, tagged_url(:tag => tag.name) %>
</span>
<%# Need end here, as illustrated on the next line. %>
<% end %>
</div>
<% end %>

Take more care about how you're indenting your code. It matters and helps you to more easily prevent and debug syntax problems like this.

syntax error, unexpected keyword_ensure, expecting keyword_end

For the if statement, you're doing an assignment with '=', we should use '==' instead.

And I think you need to use 'elsif' instead of 'else if'.

Rails syntax error: unexpected keyword_ensure, expecting keyword_end

The errors you're receiving more than likely stem from trying to execute a if-else conditional wherein you have an extra <% end %> before <% else %>. Ensure that your conditional follows canonical if-else-end logic like the following:

<% if ... %>
<% @ballot_link = "/vote/#{params[:election_id]}/ballot/#{params[:ballot_position]}" %>
<a href="<%= @ballot_link %>" class="btn btn-primary">Ready</a>
<% else %>
...
<% end %>

SyntaxError unexpected keyword_ensure, expecting keyword_end

Indentation is very important in Slim. You haven't indented anything within your first line, if user.paid?; you need to do so, or you're producing an if statement with no body.

Syntax error, unexpected keyword_ensure, expecting keyword_end

You're not properly closing the if you pasted :

    <% if current_user.admin? && !current_user?(user) %>
<li><%= link_to "Admin", users_path %></li>
</end>

You should try to replace that by :

    <% if current_user.admin? && !current_user?(user) %>
<li><%= link_to "Admin", users_path %></li>
<% end %>

syntax error, unexpected keyword_ensure, expecting keyword_end in my app

Here

  <% else %>
<%= form_for(current_user.active_relationships.find_by(followed_id: user.id), html: {method: :delete}) do |f| %>
<%= f.submit "Unfollow", class: "btn btn-default" %>
<% end %>
</center>

You have the end to close the block for form_for but not for ending the if-else

  <% else %>
<%= form_for(current_user.active_relationships.find_by(followed_id: user.id), html: {method: :delete}) do |f| %>
<%= f.submit "Unfollow", class: "btn btn-default" %>
<% end %>
<% end %>
</center>

Ruby syntax unexpected keyword_ensure, expecting keyword_end

You have two problems in your code. Your <%end> should be <%end%>. This is causing you the syntax error. But, you also should close your <ul> element. Use the following code:

<ul id="messages">
<% @messages.each do |chat| %>
<li>
<%= current_user.name %> : <%= chat.content %>
</li>
<%end%>
</ul>

Sytax error - unexpected keyword_ensure, expecting keyword_end

The problem is that you're opening a Ruby block here:

<!-- <%= form_for :question, url: '/questions', html: {class: 'form-horizontal'} do %>  -->

...but you never close it.

Keep in mind that ERB doesn't know anything about HTML, so putting ERB code inside HTML comments doesn't stop it from running. If you do <!-- <%= "foo" %> --> it'll render <!-- foo -->.

If you want to comment out ERb code, replace the opening tag with <%#:

<%#= form_for :question, url: '/questions', html: {class: 'form-horizontal'} do %>

If your block has a corresponding <% end %>, don't forget to comment that out as well:

<%#= form_for :question, url: '/questions', html: {class: 'form-horizontal'} do %>
...
<%# end %>


Related Topics



Leave a reply



Submit