S
S
sSmok2014-04-15 17:34:56
Ruby on Rails
sSmok, 2014-04-15 17:34:56

Rails - where does the extra information come from in the index view?

Hello. Getting to know Rails through Hasbrains screencasts. There was a problem, when rendering the index view, extra information about the products is displayed:

Picture
e44eb936e0a94389aae5b830ceecb5aa.png

index.erb code
<h1>Items</h1>

<% if @items.empty? %>
    <b>Айтемы отсутствуют</b>
<% else %>
    <table>
      <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Price</th>
        <th>Price</th>
      </tr>

      <%= @items.each do |i| %>
          <tr>
            <td><%= i.id %></td>
            <td><%= link_to i.name, item_path(i) %></td>
            <td><%= i.price %>руб.</td>
            <td><%= link_to 'Удалить', i, method: :delete, data: { confirm: 'Точно удалить?' } %></td>
          </tr>
      <% end %>
    </table>
<% end %>

code items_controller.rb
def index
    @items = Item.all
end

I can't figure out where it comes from. Tell me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alfss, 2014-04-15
@sSmok

<%= @items.each do |i| %> ------> <% @items.each do |i| %>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question