Manuel Manuel wrote:
> Hey everybody,
> 
> I am currently following the depot application from the book Web Agile
> Development with Rails (3rd Edition) but after creating the controller
> for the Store and the Cart model, I am always getting a nil product, no
> matter how many products I add to the database.
> I am very new with RoR (this only the page 110 of the book) and thus I
> am not very sure about what I could do to mitigate the problem.
> 
> Thanks a lot in advance!

The errors are both Cart.rb, line number 9:

def add_product(product)
    -> @items << product
end

and

def add_to_cart
    product = Product.find(params[:id])
    @cart = find_cart
 -> @cart.add_product(product)
end

Error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to