Sha256: b8458346c9b1362e86d5436f2587536cfe8d1919dc56760262e355229f8d4457

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

module ActsAsPublished
  module ActiveAdminHelper
    def acts_as_published_actions
      action_item :only => :show do
        if resource.published?
          link_to I18n.t('acts_as_published.actions.unpublish'), self.send(:"toggle_published_admin_#{resource.class.model_name.underscore.gsub("/", "_")}_path", resource)      
        else
          link_to I18n.t('acts_as_published.actions.publish'), self.send(:"toggle_published_admin_#{resource.class.model_name.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
    
    def acts_as_published_columns
      column :published do |resource|
        I18n.t(resource.published.to_s)
      end
    end
    
    def acts_as_published_rows
      row :published do |resource|
        I18n.t(resource.published.to_s)
      end
      row :published_at
    end    
  end
end  

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
acts_as_published-0.0.8.pre lib/acts_as_published/active_admin_helper.rb
acts_as_published-0.0.7.pre lib/acts_as_published/active_admin_helper.rb
acts_as_published-0.0.6.pre lib/acts_as_published/active_admin_helper.rb
acts_as_published-0.0.5.pre lib/acts_as_published/active_admin_helper.rb
acts_as_published-0.0.4.pre lib/acts_as_published/active_admin_helper.rb
acts_as_published-0.0.3.pre lib/acts_as_published/active_admin_helper.rb