module ActiveRecord::Persistence

Active Record Persistence

Public Instance Methods

update_attributes(attributes, options = {}) click to toggle source
# File lib/initializers/initialize.rb, line 56
def update_attributes(attributes, options = {})
  if timestamp_control = attributes.delete(:control_against_overwrite_by_another_user)
    if self.attributes['updated_at'] > timestamp_control
      errors[:base] << I18n.t('errors.messages.control_against_overwrite_by_another_user')
      return false
    end
  end
  with_transaction_returning_status do
    self.assign_attributes(attributes, options)
    save
  end
end
update_attributes!(attributes, options = {}) click to toggle source
# File lib/initializers/initialize.rb, line 69
def update_attributes!(attributes, options = {})
  if timestamp_control = attributes.delete(:control_against_overwrite_by_another_user)
    if self.attributes['updated_at'] > timestamp_control
      errors[:base] << I18n.t('errors.messages.control_against_overwrite_by_another_user')
      return false
    end
  end
  with_transaction_returning_status do
    self.assign_attributes(attributes, options)
    save!
  end
end