chris
2006-Aug-24 00:33 UTC
[Rails] Re: Not sure why this doesn''t work - AWDRW chapter 8 page 96 tutorial
I will mark the page and book name in future posts. Thanks for the
tip.
As for the problem I am still unable to figure it out. I reverted to
exactly the way the book did things (or at least I think it is exact)
with no luck.
I think the issue is in the return of a value from the add_to_cart
method. In addition to trying to return the item and product, I have
also tried to return a simple string value ,but still don''t see any
value in the code within the comment block
<!-- <%= @current_item %> -->
after returning a value from the model:
def add_product(product)
#determine if the product already exists within the cart
existing_item = @items.find {|item| item.product == product }
if existing_item
existing_item.increment_quantity
else
existing_item = CartItem.new(product)
@items << existing_item
end
return "It is added" #tried without the return keyword as well
end
and the controller:
@current_item = @cart.add_product(@product)
--~--~---------~--~----~------------~-------~--~----~
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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---