Module: ActiveScaffold::Actions::Mark

Defined in:
lib/active_scaffold/actions/mark.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/active_scaffold/actions/mark.rb', line 5

def self.included(base)
  if base.active_scaffold_config.model.primary_key.nil?
    raise "#{base.active_scaffold_config.model.name} has no primary key, mark won't work"
  end

  base.before_action :mark_authorized_filter, only: :mark
  base.before_action :assign_marked_records_to_model
  base.helper_method :marked_records
end

Instance Method Details

#markObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_scaffold/actions/mark.rb', line 15

def mark
  if mark? || mark_all_scope_forced?
    do_mark
  else
    do_demark
  end
  if marked_records.any?
    count = marked_records.length
    flash[:info] = as_(:records_marked, count: count, model: active_scaffold_config.label(count: count))
  end
  respond_to_action(:mark)
end