Class: Smithy::AssetsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/smithy/assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#batch_destroyObject



54
55
56
57
58
59
60
# File 'app/controllers/smithy/assets_controller.rb', line 54

def batch_destroy
  @assets = Asset.where(id: params[:ids])
  @assets.destroy_all
  respond_with @assets do |format|
    format.js { render json: { ids: params[:ids] }, callback: "assets_table_delete_rows" }
  end
end

#dataObject



62
63
64
65
# File 'app/controllers/smithy/assets_controller.rb', line 62

def data
  @asset = Asset.find(params[:id])
  send_data @asset.data, filename: @asset.file_filename, disposition: "inline", type: ::File.extname(@asset.file_filename).downcase.sub(/^\./, '').to_sym
end

#destroyObject



42
43
44
45
46
# File 'app/controllers/smithy/assets_controller.rb', line 42

def destroy
  @asset = Asset.find(params[:id])
  @asset.destroy
  respond_with @asset
end

#editObject



29
30
31
32
# File 'app/controllers/smithy/assets_controller.rb', line 29

def edit
  @asset = Asset.find(params[:id])
  respond_with @asset
end

#indexObject



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

def index
  @asset_source = AssetSource.first
  respond_with @assets do |format|
    format.html
    format.json { render json: ::Smithy::AssetsDatatable.new(view_context, params[:type]) }
  end
end

#newObject



24
25
26
27
# File 'app/controllers/smithy/assets_controller.rb', line 24

def new
  @asset = Asset.new(filtered_params)
  respond_with @asset
end

#selector_modalObject



48
49
50
51
52
# File 'app/controllers/smithy/assets_controller.rb', line 48

def selector_modal
  respond_to do |format|
    format.html { render :layout => 'smithy/modal' }
  end
end

#showObject



17
18
19
20
21
22
# File 'app/controllers/smithy/assets_controller.rb', line 17

def show
  @asset = Asset.find(params[:id])
  respond_with @asset do |format|
    format.html { redirect_to @asset.url }
  end
end

#updateObject



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

def update
  @asset = Asset.find(params[:id])
  flash.notice = "Your asset was saved" if @asset.update_attributes(filtered_params)
  respond_with @asset do |format|
    format.html { redirect_to assets_path }
  end
end