Sha256: 9a129f84c8364b4d8bdbc8a0564ce5ea7de10a596fb0651bd2da20e2d6a343e1

Contents?: true

Size: 795 Bytes

Versions: 11

Compression:

Stored size: 795 Bytes

Contents

# coding: utf-8

class Redditor::Admin::ImagesController < Redditor::Admin::BaseController

  layout false

  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

  def create
    @slider_block = @page.slider_blocks.find(params[:slider_block_id])
    @image = @slider_block.images.build(src: params[:file])
    if @image.save
      render "redditor/admin/pages/slider_block_image"
    end
  end

  def destroy
    @image = Redditor::Image.find(params[:id])
    if @image.destroy
      render :js => "$('#slider_block_image_#{@image.id}').remove()"
    else
      render :js => 'Ошибка! Изображение не было удалено.'
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
redditor-0.1.10 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.9 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.8 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.7 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.6 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.5 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.4 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.3 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.2 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.1 app/controllers/redditor/admin/images_controller.rb
redditor-0.1.0 app/controllers/redditor/admin/images_controller.rb