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 toproduct
andcart
models. Do we need an x m
relationship between product and cart models? Because of that we create theline_item
model? -
Also inside the
product
andcart
models we havehas_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 attributeproduct_id
. Any helps solving this problem
Thank you @rubys for this book!
Have a great day!
Mert