Module: ActiveRecord::SaveExtensions
- Defined in:
- lib/webget_ramp/active_record/save_extensions.rb
Instance Method Summary collapse
-
#save_false_then_reload! ⇒ Object
Save the record without validation, then reload it.
-
#save_redux! ⇒ Object
Save the record without validation, then reload, then save with validtion.
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])
Deprecated, superceded by #save_redux!
11 12 13 14 15 16 17 18 |
# File 'lib/webget_ramp/active_record/save_extensions.rb', line 11 def save_false_then_reload! transaction do save(false) reload valid? or raise ActiveRecord::RecordInvalid.new(self) end return true end |
#save_redux! ⇒ Object
Save the record without validation, then reload, then save with validtion. This ensure that rails brings back the correct associations to validate. This solves an issue we found with Rails associations not saving.
25 26 27 28 29 30 31 32 |
# File 'lib/webget_ramp/active_record/save_extensions.rb', line 25 def save_redux! transaction do save(false) reload save! end return true end |