Sha256: e0988ba3424e39078830f0d1faba628fb56a1bfd4b98870c1c48efdc9e4235e0

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

class PublicationsController < ApplicationController
  
  def create
    if unpublished_resource.publish!
      flash[:notice] = I18n.t('flash.publications.create.notice', :default => "#{resource.class.human_name} published successfully")
    end
    respond_to do |format|
      format.html {redirect_to :back}
    end
  end
  
  def destroy
    if published_resource.unpublish!
      flash[:notice] = I18n.t('flash.publications.destroy.notice', :default => "#{resource.class.human_name} unpublished successfully")
    end
    respond_to do |format|
      format.html {redirect_to :back}
    end
  end
  
  protected
    def unpublished_resource
      @resource ||= resource_class.unpublished.find(params[:id])
    end
    
    def published_resource
      @resource ||= resource_class.published.find(params[:id])
    end
    
    def resource
      @resource
    end
    
    def resource_class
      params[:resource].camelize.constantize
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aguids-publishable-0.1.1 app/controllers/publications_controller.rb
aguids-publishable-0.1.2 app/controllers/publications_controller.rb
aguids-publishable-0.1.3 app/controllers/publications_controller.rb