Class: Fae::ImagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Fae::ImagesController
- Defined in:
- app/controllers/fae/images_controller.rb
Instance Method Summary collapse
-
#crop_image ⇒ Object
the initial crop view + handling of actual crop.
-
#delete_image ⇒ Object
ajax delete action.
Methods included from NavItems
Instance Method Details
#crop_image ⇒ Object
the initial crop view + handling of actual crop
get ‘images/:id/crop_image’ => ‘images#crop_image’, as: :crop_image patch ‘images/:id/crop_image’ => ‘images#crop_image’, as: :commit_crop
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/fae/images_controller.rb', line 8 def crop_image @image = Image.where(id: params[:id]).first @sizing_info = Image.sizing_info if image_params.present? if @image.update(image_params) #image model has a virtual attr: redirect. this will make redirects for submit and cancel #actions much easier to deal with especially for nested resources! #this is set automatically with request.path in image_uploader partial redirect_to(image_params[:redirect]) end end 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.
26 27 28 29 30 31 |
# File 'app/controllers/fae/images_controller.rb', line 26 def delete_image image = Image.find_by_id(params[:id]) image.remove_asset = true image.save render :nothing => true end |