Hannes Nose
Hannes Nose

Reputation: 21

A beginner ROR Error

<h1>All Articles</h1>

<ul>
   <% @articles.each.do |article| %>
  <li>
     <%= article.title %>
  </li>
 <% end %>
</ul>

I keep getting "syntax error, unexpected keyword_ensure, expecting $end" I am totally confused on whats going on.

Upvotes: 2

Views: 41

Answers (1)

Veraticus
Veraticus

Reputation: 16084

do is not a method of each: it's a signifier for the beginning of a block. You want this:

<h1>All Articles</h1>

<ul>
   <% @articles.each do |article| %>
  <li>
     <%= article.title %>
  </li>
 <% end %>
</ul>

Upvotes: 1

Related Questions