I'm starting learn Ruby on Rails, and started with a basic CRUD. A problem I'm having is in the index view: everything that I saved is showed, but also an array with everithing saved is returned.
The index method in my controller:
def index
@categories = Category.all
end
My view:
<%= @categories.each do |c| %>
<table>
<tr>
<td> <%= c.name %> </td>
</tr>
</table>
<% end %>
<%= link_to 'New category', "/categories/new" %>
What is showed in the browser:
Healt
Supermarket
[#<Category id: 13, name: "Healt", created_at: "2016-02-17 13:30:22", updated_at: "2016-02-17 13:30:22">, #<Category id: 14, name: "Supermarket", created_at: "2016-02-17 13:30:42", updated_at: "2016-02-17 13:30:42">]New category
Why that happens? How can I avoid that?