Module: Dunlop::LastAttributeChangeHelper
- Defined in:
- app/helpers/dunlop/last_attribute_change_helper.rb
Instance Method Summary collapse
Instance Method Details
#last_changed_info(target, attr) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'app/helpers/dunlop/last_attribute_change_helper.rb', line 2 def last_changed_info(target, attr) if target.is_a?(RecordCollection::Base) changes = target.map{|r| r.last_changed[attr] }.compact.uniq else # must be a ActiveRecord::Base changes = [target.last_changed[attr]].compact end return nil if changes.empty? return t('collection.last_changed.mixed_values') if changes.size > 1 changes.map{|c| I18n.localize(c, format: '%-e %b %-k:%M') }.join(', ') end |