Class: Admin::AssetsController

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

Instance Method Summary collapse

Instance Method Details

#batch_editObject


31
32
33
34
# File 'app/controllers/admin/assets_controller.rb', line 31

def batch_edit
  @assets = Asset.includes(:translations).find(params[:ids])
  render layout: false
end

#batch_updateObject


36
37
38
39
# File 'app/controllers/admin/assets_controller.rb', line 36

def batch_update
  Asset.update(params[:data].keys, params[:data].values)
  head :ok
end

#createObject


9
10
11
12
13
14
15
16
17
# File 'app/controllers/admin/assets_controller.rb', line 9

def create
  @asset = build_asset(permitted_params)
  @asset.guid = params[:guid]
  @asset.data = prepared_data
  @asset.user = current_user
  @asset.save!

  render json: @asset
end

#cropObject


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

def crop
  render json: @asset.crop!(params[:geometry])
end

#destroyObject


19
20
21
22
# File 'app/controllers/admin/assets_controller.rb', line 19

def destroy
  @asset.destroy!
  head :ok
end

#mainObject


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

def main
  render json: @asset.main!
end

#rotateObject


41
42
43
# File 'app/controllers/admin/assets_controller.rb', line 41

def rotate
  render json: @asset.rotate!
end

#sortObject


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

def sort
  params[:asset].each_with_index do |id, index|
    @klass.move_to(index, id)
  end
  head :ok
end