質問です。この <% @items.zip(@user〜 のコードにindex 番号をつけたいです。
どなたか分かる方いらっしゃいますか?
Syntax error.
<% @items.zip(@user_items).with_index do |item, ui, index| %>
<td class="invert"><%= index %></td>
<% end %>
show.html.erb
<% @items.zip(@user_items).with_index do |item, ui, index| %>
<tr class="rem1">
<td class="invert"><%= index %></td>
<td class="invert-image" >
<%= link_to image_tag(item.img.thumb.url || "sushi1.jpg", class: "img-responsive" ), item %>
</td>
<td class="invert">
<div class="quantity">
<div class="quantity-select">
<div class="entry value-minus"> </div>
<div class="entry value" id="score-value"><%= ui.quantity %></div>
<div class="entry value-plus active"> </div>
</div>
</div>
</td>
<td class="invert"><%= link_to item.name, item %></td>
<td class="invert">$ <%= link_to item.price, item %></td>
<td class="invert">
<%= link_to image_tag("close_1.png"), item_delete_in_baskets_path(item), method: :post, data: { confirm: "You sure?" }, class:"ml-2"%>
</td>
</tr>
<% end %>
baskets_contrller.rb
class BasketsController < ApplicationController
before_action :authenticate_user!
def show
# same as application controller
basket = current_user.prepare_basket
@user_items = basket.basket_items
@basket_items = @user_items.select(:item_id)
@items = Item.where(id: @basket_items)
@total_price = basket.total_price
end
end