ruby on rails - add a record to has_many model without saving -
A customer has many orders, so the customer.order gives me all the orders.
I want to add an order to my order but for internal investigation, I do not want this order to be actually added to the data base.
But while doing so:
customer.orders & lt; & Lt; Test_order
It is being saved and committed to the data base.
How can I add it to my use without saving it? You can use Build, which will initialize the order object without saving it.
test_order = customer .orders.build (order_params)
Comments
Post a Comment