Module: ActiveRecord::SaveExtensions

Defined in:
lib/webget_ramp/active_record/save_extensions.rb

Instance Method Summary collapse

Instance Method Details

#save_false_then_reload!Object

Save the record without validation, then reload it. If the record is valid then return true, otherwise raise RecordInvalid. This solves an issue we found with Rails associations not saving.

By Andrew Carpenter ([email protected])



12
13
14
15
16
17
18
19
# File 'lib/webget_ramp/active_record/save_extensions.rb', line 12

def save_false_then_reload!
  transaction do
    save(false)
    reload
    valid? or raise ActiveRecord::RecordInvalid.new(self)
  end
  return true
end