I am currently developing a cart which will take the id of the CD or a DVD, it then gets the name of the item.
If I use them individually it works fine as I have made the relevant changes in the other files.
The code currently is:
<% 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>
If I have a <td><%= line_item.cd.name %></td> line and only add CDs it works fine, and vice-versa with this line <td><%= line_item.dvd.name %></td>.
What I want is it to do a test to see if cd.name is nil and if it is use the dvd.name, but this is not working.
This should work
This code will first try to get CD name and fallback to DVD if either
cdorcd.nameis nil.