Sha256: 035976004e2a4a27281fcc4cc8a890c240323986327e70d8aa1f8cf827695172

Contents?: true

Size: 528 Bytes

Versions: 1

Compression:

Stored size: 528 Bytes

Contents

module ActiveRecord::SaveExtensions

  # 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 (acarpen@wested.org)

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

end
ActiveRecord::Base.send(:include, ActiveRecord::SaveExtensions)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webget_ramp-1.7.1.6 lib/webget_ramp/active_record/save_extensions.rb