On 11 February 2017 at 01:55, Joe Guerra <email@example.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.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
To post to this group, send email to email@example.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvs154YHGUu5dAToV_t8CpkDVuDUE8233f_Zdnh9nDBTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.