Module: Adminpanel::GalleryActions
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- app/controllers/concerns/adminpanel/gallery_actions.rb
Instance Method Summary collapse
Instance Method Details
#add_to_gallery ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/concerns/adminpanel/gallery_actions.rb', line 5 def add_to_gallery image_class = params[:model].camelize.constantize image = image_class.new(file: params[:file], model_type: params[:parent_object_class]) image.model_id = params[:resource_id] if params[:resource_id] if image.save response = { class: image_class.to_controller_name, id: image.id, image_url: image.file_url(:thumb) } respond_to do |f| f.json{ render status: :ok, json: response.to_json } end end end |
#remove_image ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/controllers/concerns/adminpanel/gallery_actions.rb', line 22 def remove_image @image = params[:model].constantize.find(params[:id]) @image.destroy respond_to do |f| f.json{ render status: :ok, json: @image.to_json } end end |