Я работаю над учебником по депо в Agile RoR.Я смотрел на это некоторое время и не вижу ошибки.Что мне не хватает?Я получаю следующую ошибку при добавлении товара в корзину
Я запустил миграцию.
.. /Users/computername/.gem/ruby/1.8/gems/activerecord-2.3.5 / lib / active_record / association / association_collection.rb: 376: в method_missing'
/Users/computername/Documents/rails_projects/depot/app/models/cart.rb:5:in
add_product '/Users/computername/Documents/rails_projects/depot/app/controllers/line_items_controller.rb:46:in `create'
Вот мой метод создания
def create
@cart = find_or_create_cart
product = Product.find(params[:product_id])
#@line_item = @cart.line_items.build(:product => product)
@line_item = @cart.add_product(product.id)
..
модель моей корзины
class Cart < ActiveRecord::Base
has_many :line_items, :dependent => :destroy
def add_product(product_id)
current_item = line_items.where(:product_id => product_id).first
if current_item
current_item.quantity += 1
else
current_item = LineItem.new(:product_id=>product_id)
line_items << current_item
end
current_item
end
end