Module: ResourceRow::TimestampExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/extensions/concerns/resource_row/timestamp_extensions.rb

Instance Method Summary collapse

Instance Method Details

#column_timestampsObject



18
19
20
21
# File 'app/extensions/concerns/resource_row/timestamp_extensions.rb', line 18

def column_timestamps
  ActiveSupport::Deprecation.warn('Do not use table.column_timestamps. Use table.timestamps instead!')
  timestamps
end

#timestamp(attribute_name, options = {}) ⇒ Object



7
8
9
10
11
# File 'app/extensions/concerns/resource_row/timestamp_extensions.rb', line 7

def timestamp(attribute_name, options = {})
  options.reverse_merge!(format: :short)
  format = options.delete(:format)
  column(attribute_name) { |resource| I18n.l(resource.send(attribute_name), format: format) if resource.send(attribute_name).present? }
end

#timestampsObject



13
14
15
16
# File 'app/extensions/concerns/resource_row/timestamp_extensions.rb', line 13

def timestamps
  timestamp :created_at
  timestamp :updated_at
end