After looping trough table, rails displays an array of complete table

I’m trying to make a blog in Ruby on rails and I want to display the posts table in my view. Simple as my good looks, something manages to fail. After looping trough the whole table, and rendering the records to my view, it also renders an array with the complete table to my view.
the index view

The code that creates this view is this:

<%= @posts.each do |post| %>
    <div class="post_wrapper"> 
        <h1 class="title">
          <%= post.title %>

        <p class="date">
          Submitted <%= time_ago_in_words(post.created_at) %> Ago

        <p class="body">
          <%= post.body %>
    <p style="color:red; font-size:1.5em;">the array is added after the div</p>
<p style="color:red; font-size:1.5em;">but still inside the loop</p>
<br />
<%= link_to "New post", new_post_path %>

Source: ruby

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.