Module: ActsAsPublished::ActiveAdminHelper

Defined in:
lib/acts_as_published/active_admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_published_actionsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/acts_as_published/active_admin_helper.rb', line 3

def acts_as_published_actions
  action_item :publish, :only => :show do
    if resource.published?
      link_to I18n.t('acts_as_published.actions.unpublish'), self.send(:"toggle_published_#{active_admin_config.namespace.name}_#{resource.class.model_name.to_s.underscore.gsub("/", "_")}_path", resource)
    else
      link_to I18n.t('acts_as_published.actions.publish'), self.send(:"toggle_published_#{active_admin_config.namespace.name}_#{resource.class.model_name.to_s.underscore.gsub("/", "_")}_path", resource)
    end
  end

  batch_action :toggle_published do |selection|
    active_admin_config.resource_class.find(selection).each do |item|
      item.toggle_published!
    end
    redirect_to :back
  end

  member_action :toggle_published do
    resource.toggle_published!
    if resource.published?
      redirect_to :back, :notice => I18n.t('acts_as_published.notices.published', :name => resource )
    else
      redirect_to :back, :notice => I18n.t('acts_as_published.notices.unpublished', :name => resource )
    end
  end
end

#acts_as_published_columnsObject



29
30
31
32
33
# File 'lib/acts_as_published/active_admin_helper.rb', line 29

def acts_as_published_columns
  column :published do |resource|
    I18n.t(resource.published.to_s)
  end
end

#acts_as_published_rowsObject



35
36
37
38
39
40
# File 'lib/acts_as_published/active_admin_helper.rb', line 35

def acts_as_published_rows
  row :published do |resource|
    I18n.t(resource.published.to_s)
  end
  row :published_at
end