Module: AbAdmin::Models::Track

Extended by:
ActiveSupport::Concern
Included in:
Track
Defined in:
lib/ab_admin/models/track.rb

Instance Method Summary collapse

Instance Method Details

#action_title(params = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ab_admin/models/track.rb', line 25

def action_title(params = {})
  parts = key.split('.')
  lookups = []
  if parts.length == 2
    lookups << [parts[0], 'actions', parts[1], 'title']
    lookups << [parts[0], 'actions', parts[1]]
    lookups << ['actions', parts[1], 'title']
  else
    lookups << ['actions', key, 'title']
    lookups << ['actions', key]
  end
  lookups.map!{|l| l.join('.').to_sym }
  lookups << key

  I18n.t(lookups.shift, (parameters.merge(params) || {}).merge(scope: :admin, default: lookups))
end

#trackable_changed_attrsObject



42
43
44
45
# File 'lib/ab_admin/models/track.rb', line 42

def trackable_changed_attrs
  return unless trackable
  trackable_changes.keys.map { |attr| trackable_han(attr) }.join(', ')
end

#trackable_han(attr) ⇒ Object



47
48
49
50
# File 'lib/ab_admin/models/track.rb', line 47

def trackable_han(attr)
  attr_s = attr.to_s
  trackable.class.han attr_s =~ /_ids$/ ? attr_s.sub(/_ids$/, '').pluralize : attr_s
end