nice.

On 30 Dez., 10:12, "Jeffrey L. Taylor" <r...@abluz.dyndns.org> wrote:
> Quoting Ryan Ororie <rails-mailing-l...@andreas-s.net>:
> [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 rubyonrails-talk@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