Module: Elabs::ActsHelper

Defined in:
app/helpers/elabs/acts_helper.rb

Instance Method Summary collapse

Instance Method Details

#act_action(action) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/elabs/acts_helper.rb', line 3

def act_action(action)
  actions = {
    create:    _('created'),
    update:    _('updated'),
    lock:      _('locked'),
    unlock:    _('unlocked'),
    publish:   _('published'),
    unpublish: _('removed from publication')
  }.freeze
  actions[action.to_sym] || "[missing: #{action}]"
end

#act_notice_string(act) ⇒ Object



15
16
17
18
19
20
# File 'app/helpers/elabs/acts_helper.rb', line 15

def act_notice_string(act)
  string = format('%<type>s #%<id>i', type: act.content_type.demodulize, id: act.content_id)
  string = link_to string, act.content unless %w[unpublish destroy lock].include? act.event

  format(_('%<string>s has been %<event>s'), string: string, event: act_action(act.event)).html_safe
end