Class: Redditor::Admin::ImagesController
- Inherits:
-
BaseController
- Object
- BaseController
- Redditor::Admin::ImagesController
- Defined in:
- app/controllers/redditor/admin/images_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/controllers/redditor/admin/images_controller.rb', line 16 def create = @page..find(params[:slider_block_id]) @image = .images.build(src: params[:file]) if @image.save render "redditor/admin/pages/slider_block_image" end end |
#destroy ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/controllers/redditor/admin/images_controller.rb', line 24 def destroy @image = Redditor::Image.find(params[:id]) if @image.destroy render :js => "$('#slider_block_image_#{@image.id}').remove()" else render :js => 'Ошибка! Изображение не было удалено.' end end |
#sort ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/controllers/redditor/admin/images_controller.rb', line 7 def sort params[:slider_block_image].each_with_index do |id, idx| p = Redditor::Image.find(id) p.position = idx p.save end render :nothing => true end |