I have two models, product and order.
Product
- cost
- id
Order
- cost
- product_id
Each time someone places an order, it captures the product_id through a radio button value in the "new order" form.
In the controller when creating the new order it needs to set order.cost to order.product.cost. Logically I thought the code should be something like this:
def create
...
@order.cost == @order.product.cost
...
end
However I can't seem to make it work at all, hence me asking the question here.
Any help is answering (or naming) the question would be greatly appreciated.