"carts" plural is an unusual pattern - a single cart with multiple items
is more typical, and to my mind maps more closely to the physical
world's idea of a "shopping cart".
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.