Module: Moribus::Extensions::HasAggregatedExtension

Defined in:
lib/moribus/extensions/has_aggregated_extension.rb

Overview

Minor extension for Rails’ belongs_to association that will correct foreign key assignment during association autosave.

Defined Under Namespace

Classes: Helper

Instance Method Summary collapse

Instance Method Details

#updated?Boolean

Return true if the association has an @updated value (set by default Rails behavior) or if the target record was updated during lookup, indicating that the association owner’s foreign key should be updated also.

Returns:

  • (Boolean)


10
11
12
# File 'lib/moribus/extensions/has_aggregated_extension.rb', line 10

def updated?
  @updated || target.try(:updated_as_aggregated?)
end