I am create an active record association that I use in a form. I have two models and one form. I am creating a customer_order
and payment
at the same time. That all works as planned, what I am having trouble with is I want to add the user_id to the Payments table, it adds it to the customer_order perfectly.
@customer_order.payments.build(:payment_amt => @mailer.full_price, :user_id => current_user.id)
When I click the create on the form, I am losing the user_id
. I understand that I do not want to store the user_id in a hidden field in the form. But when the program hits the create. I would like to either add the user_id
before the save (ideally) or after.
I am able to save it in the customer_order
, but not sure how to save it in the Payment
table.
@customer_order.user_id = current_user.id
@customer_order.save
I am a rails newbie so go easy on me.