Quoting Ryan Ororie <[email protected]>:
[snip]
> def add_product(product)
> current_item = @items.find {|item| item.product == product}
> if current_item
> current_item.increment_quantity
> else
> @items << CartItem.new(product)
> end
> end
> end
>
Your code is calling the ActiveRecord find() which takes an argument or more.
You are intending the Array method. It has an alias, detect. Change the line
above to:
current_item = @items.detect {|item| item.product == product}
Someone on this list answer my similar question a year or two ago. I pass the
"each one, teach one" obligation on to you.
Grin,
Jeffrey
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---