Agile Depot Tutorial Help

anyone can explain me why in the Agile Depot Tutorial application they
use i.product_id
to find if a product already exist in the cart, because the cart
contains items, each of them references a product.

I tried i.product_id like in the tutorial

all of these 2 notation works , but i find the second seems more
clean??? isn’t it.

Any explanation will be fine


I"m a Nuby so I could be wrong…

What this code is doing is just checking for the existence of a
product corresponding to the value stored in “i”. It doesn’t matter
what attribute of that product you ask for, the result will be the
same. Presuming products have a name attribute, you could as easily

and get the same result.

product_id is one of those amazing Rails freebies that just makes
good coding sense to use.

At least that’s my take.

On Jan 5, 2006, at 1:53 AM, Luciano B. wrote:

clean??? isn’t it.

Any explanation will be fine


Rails mailing list
[email protected]

Dan S.
Technology Visionary - Technology Assessment - Documentation
“Looking at technology from every angle”

i.product_id and both work because the LineItem object has
product_id Integer property and a project Product property. It gets the
product_id property from the line_item database table, product_id colum.
The project property comes from the belongs_to in the LineItem class
in app/models/line_items.rb

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs