Agile Web Development with Rails 7: [solved]

Hello everyone,

I am relatively new to rails. I am reading AWDWR 7.

I am at page 120, I have some questions and having some problems.

Questions:

  • In line_item model we create a relationship to product and cart models. Do we need a n x m relationship between product and cart models? Because of that we create the line_item model?

  • Also inside the product and cart models we have has_many :line_items. Where is these relationships inside our schema.rb? I don’t see any sql relationship? If we don’t have a sql relationship is it good way to create relationships in ruby?

Need help code debugging:

  • I think I am having some problem. inside the line_items_controller.rb in the create method at @line_item = @cart.line_items.build(product: product) it gives me error. Saying : ActiveModel::MissingAttributeError in LineItemsController#create
    can’t write unknown attribute product_id. Any helps solving this problem

Thank you @rubys for this book!

Have a great day!

Mert