CD-RUM CD-RUM - 1 year ago 76
Ruby Question

Rails: set params but do not save

What's the call to update a Rails record with new params, say, stored in a

variable? This:


Will save the record, and since I want to put the call in a callback I don't want to save it, just prepare it to be saved correctly in the callback.

Answer Source

You can use attributes= to set the attributes but not save the record.

@user.attributes = hash

New attributes will be persisted in the database when the object is saved. See

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download