On 11 February 2017 at 01:55, Joe Guerra <
jgu...@jginfosys.com> wrote:
> I"m building a basic cart system, one item per cart. I'm still trying to
> learn ruby on rails.
In that case you want Cart belongs_to product and Product has_many
carts (the verb has_many can be confusing, it really means
is_associated_with_many), then to get the product for a cart you use
cart.product in your carts loop. Eventually when the cart can have
many products you can use Cart has_many_and_belongs_to product, and
vice versa, but I usually recommend using an explicit join table
rather the the automatic table that has_many_and_belongs_to generates.
I am sure that was covered in
railstutorial.org.
Colin