Module: Switchman::ActiveRecord::AutosaveAssociation

Defined in:
lib/switchman/active_record/association.rb

Instance Method Summary collapse

Instance Method Details

#record_changed?(reflection, record, key) ⇒ Boolean

Returns:

  • (Boolean)


180
181
182
183
184
# File 'lib/switchman/active_record/association.rb', line 180

def record_changed?(reflection, record, key)
  record.new_record? ||
    (record.has_attribute?(reflection.foreign_key) && record.send(reflection.foreign_key) != key) || # have to use send instead of [] because sharding
    record.attribute_changed?(reflection.foreign_key)
end