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
|