Class: Fae::ImagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Fae::ImagesController
- Defined in:
- app/controllers/fae/images_controller.rb
Instance Method Summary collapse
-
#create_html_embedded ⇒ Object
ajax action.
-
#delete_image ⇒ Object
ajax delete action.
Instance Method Details
#create_html_embedded ⇒ Object
ajax action
Called from the Trumbowyg JS wysiwyg editor when embedding images to a HTML field.
21 22 23 24 |
# File 'app/controllers/fae/images_controller.rb', line 21 def image = Image.create! asset: params[:image] render json: { success: true, file: image.asset.url } end |
#delete_image ⇒ Object
ajax delete action
post ‘images/:id/delete_image’ => ‘images#delete_image’, as: :delete_image here we just remove the asset from the attached image model, because if we deleted the model itself, re-uploading a new one would break.
9 10 11 12 13 14 15 |
# File 'app/controllers/fae/images_controller.rb', line 9 def delete_image image = Image.find_by_id(params[:id]) image.remove_asset = true image.save CarrierWave.clean_cached_files! head :ok end |