Class: Admin::AssetsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/admin/assets_controller.rb', line 9

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

#cropObject



52
53
54
# File 'app/controllers/admin/assets_controller.rb', line 52

def crop
  render :json => @asset.crop!(params[:crop_attrs])
end

#destroyObject



25
26
27
28
29
30
31
32
# File 'app/controllers/admin/assets_controller.rb', line 25

def destroy
  @asset.destroy

  respond_with(@asset) do |format|
    format.html { head :ok }
    format.xml { render :xml => @asset.to_xml }
  end
end

#mainObject



48
49
50
# File 'app/controllers/admin/assets_controller.rb', line 48

def main
  render :json => @asset.main!
end

#rotateObject



44
45
46
# File 'app/controllers/admin/assets_controller.rb', line 44

def rotate
  render :json => @asset.rotate!
end

#sortObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/admin/assets_controller.rb', line 34

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