Undefined local variable or method `product_price'
Приветствую. Начал разбираться с RoR.
Получил ошибку:
app/views/carts/show.html.erb where line #11 raised:
undefined local variable or method `product_price' for #<LineItem:0x00000004de5ef0>
app/models/line_item.rb
class LineItem < ActiveRecord::Base
belongs_to :product
belongs_to :cart
def total_price
product_price * quantity
end
end
app/views/carts/show.html.erb
<% if notice %>
<p id="notice"><%= notice %></p>
<% end %>
<h2>Корзина</h2>
<table>
<% @cart.line_items.each do |item| %>
<tr>
<td><%= item.quantity %> ×</td>
<td><%= item.product.title %></td>
<td class="item_price"><%= number_to_currency(item.total_price) %></td>
</tr>
<% end %>
<tr class="total_line">
<td colspan="2">Total</td>
<td class="total_call"><%= number_to_currency(@cart.total_price) %></td>
</tr>
</table>
<ul>
<li><%= item.quantity %> Х <%= item.product.title %></li>
</ul>
<%= button_to 'Empty cart', @cart, metod: :delete, data: {confirm:'A you shure?'} %>
<%= link_to 'Edit', edit_cart_path(@cart) %> |
<%= link_to 'Back', carts_path %>
Что я делаю не так?)
Источник: Stack Overflow на русском