Sha256: 021f6cb6aedf8c6c42dc530d20020c8f2e15a3ada1d94579823c362d476d6afc

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

class Manage::AssetsController < Manage::BaseController
  before_filter :find_klass, :only => [:create, :sort]
  before_filter :find_asset, :only => [:destroy]
  
  respond_to :html, :xml
  
  authorize_resource
  
  def create
    @asset = @klass.new(params[:asset])
    
  	@asset.assetable_type = params[:assetable_type]
		@asset.assetable_id = params[:assetable_id] || 0
		@asset.guid = params[:guid]
  	@asset.data = params[:data]
  	@asset.user = current_user
    @asset.save
    
    respond_with(@asset) do |format|
      format.html { head :ok }
      format.xml { render :xml => @asset.to_xml }
    end
  end
  
  def destroy
    @asset.destroy
    
    respond_with(@asset) do |format|
      format.html { head :ok }
      format.xml { render :xml => @asset.to_xml }
    end
  end
  
  def sort
    params[:asset].each_with_index do |id, index|
      @klass.move_to(index, id)
    end
    
    respond_with(@klass) do |format|
      format.html { head :ok }
    end
  end
  
  protected
  
    def find_asset
      @asset = Asset.find(params[:id])  
    end
    
    def find_klass
      @klass = params[:klass].blank? ? Asset : params[:klass].classify.constantize
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sunrise-core-0.2.2 app/controllers/manage/assets_controller.rb
sunrise-core-0.2.1 app/controllers/manage/assets_controller.rb
sunrise-core-0.2.0 app/controllers/manage/assets_controller.rb
sunrise-core-0.1.5 app/controllers/manage/assets_controller.rb
sunrise-core-0.1.4 app/controllers/manage/assets_controller.rb