Class: Smithy::AssetsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Smithy::AssetsController
- Defined in:
- app/controllers/smithy/assets_controller.rb
Instance Method Summary collapse
- #batch_destroy ⇒ Object
- #data ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #selector_modal ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#batch_destroy ⇒ Object
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 |
#data ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
29 30 31 32 |
# File 'app/controllers/smithy/assets_controller.rb', line 29 def edit @asset = Asset.find(params[:id]) respond_with @asset end |
#index ⇒ Object
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 |
#new ⇒ Object
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_modal ⇒ Object
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 |
#show ⇒ Object
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 |
#update ⇒ Object
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 |