简体   繁体   中英

Ruby syntax unexpected keyword_ensure, expecting keyword_end

So, i'm getting this error in the cool view, around lines 16 and 18:

app/views/gif/cool.html.erb:16: syntax error, unexpected keyword_ensure, expecting keyword_end

app/views/gif/cool.html.erb:18: syntax error, unexpected end-of-input, expecting keyword_end

I have no idea what I'm missing (I started learning Rails yesterday and I really didn't know much about ruby). Am I missing an <% end %>?

<ul id="messages">
<% @messages.each do |chat| %>
    <li>
        <%= current_user.name %> : <%= chat.content %>
    </li>
<%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>

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