I'd like to know if there is a way to bind params to an existing object in order to edit it. I'd like to do something like this, but to edit the object :
@object = Object.new(params[:object])
So something like :
@object = Object.find(params[:object_id])
@object.edit(params[:object])
params[:object]
comes from a form_for
Any idea ?
You can use
@object.assign_attributes(params[:object])
or
@object.attributes = params[:object]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With