私は現在、CD または DVD の ID を取得するカートを開発しています。その後、アイテムの名前を取得します。
それらを個別に使用すると、他のファイルに関連する変更を加えているため、正常に機能します。
現在のコードは次のとおりです。
<% if line_item==@current_item %>
<tr id='current_item'>
<% else %>
<tr>
<% end %>
<td><%= line_item.quantity %>×</td>
<td><%= line_item.product.name %></td>
<td><%= line_item.dvd.name %></td>
<td class="item_price"><%= number_to_currency(line_item.total_price, :unit=>'£') %></td>
</tr>
回線があり、CD のみを追加すると正常に<td><%= line_item.cd.name %></td>
動作し、この回線ではその逆<td><%= line_item.dvd.name %></td>
です。
私が望むのは、テストを行って を使用するかどうかcd.name
を確認することですが、これは機能していません。nil
dvd.name