M
M
Matvey Mamonov2016-02-16 18:59:58
Ruby on Rails
Matvey Mamonov, 2016-02-16 18:59:58

Why are there extra lines in the view when using the .each method?

Reading the Rails documentation. There is an example of displaying all articles on the page. For this, the following code is used:

<% @articles.each do |article| %>
    <tr>
      <td><%= article.title %></td>
      <td><%= article.text %></td>
    </tr>
  <% end %>

But, for some reason, along with the necessary output, the array itself is also output, as if I output it using the 'p' method. Actually, why?
b83bcd8a680743fb82c1be8ff8c88a36.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Burmakin, 2016-02-16
@eucalipt

Because you actually have <%= on the first line, not <%.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question