"Attempt to call private method" with depot tutorial
In my "cart.rb" model I have
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
And in "line_items_controller.rb" I have
def create
@cart = find_or_create_cart
product = Product.find(params[:product_id])
@line_item = @cart.add_product(product.id)
.....
When I select an item to add it to the cart I get a "Attempt to call private method" error.
Application trace is
/Users/machinename/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:236:in `method_missing'
/Users/machinename/Documents/rails_projects/depot/app/controllers/line_items_controller.rb:46:in `create'
I saw some discussion of an error similar and it sounded like the answer was upgrade to ruby 1.9 (I am using 1.8.7). Is that the answer or is there another possible cause of this?