Skip to content

Persistence

mech edited this page Sep 23, 2014 · 3 revisions

When creating a new record, any nil value will be ignored. If you want to overwrite this, supply an empty string.

job = Job.new(title: '', salary: 4500)
job.save
job.title # => nil

If you use update_attributes and pass in nil value, it will persist to FileMaker rather than being ignored.

job = Job.first
job.update_attributes(title: nil)

If you assign a nil value directly, it will be ignored.

job = Job.first
job.title = nil
job.save

So the best way to persist nil value or if you want to wipe out field value, is to use update_attributes.

update_attributes will only update dirty attributes, while update will update the entire attributes.

Clone this wiki locally