Class: Kms::AssetsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Kms::AssetsController
- Defined in:
- app/controllers/kms/assets_controller.rb
Instance Method Summary collapse
- #ckeditor ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#ckeditor ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/kms/assets_controller.rb', line 21 def ckeditor @asset = Asset.new(file: params[:upload]) if @asset.save render text: %Q"<script type='text/javascript'> window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{@asset.file.url}'); </script>" else render text: %Q"<script type='text/javascript'> window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, null, '#{@asset.errors..first}'); </script>" end end |
#create ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/kms/assets_controller.rb', line 11 def create @asset = Asset.new(asset_params) if @asset.save # special json for ng-flow render json: { success: true, files: [@asset] }.to_json else render json: { errors: @asset.errors. }.to_json, status: :unprocessable_entity end end |
#destroy ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/kms/assets_controller.rb', line 48 def destroy @asset = Asset.find(params[:id]) @asset.destroy head :no_content end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/kms/assets_controller.rb', line 7 def index render json: Asset.all end |
#show ⇒ Object
43 44 45 46 |
# File 'app/controllers/kms/assets_controller.rb', line 43 def show @asset = Asset.find(params[:id]) render json: @asset end |
#update ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/controllers/kms/assets_controller.rb', line 34 def update @asset = Asset.find(params[:id]) if @asset.update(asset_params) render json: @asset else render json: { errors: @asset.errors. }.to_json, status: :unprocessable_entity end end |