Sha256: ba2f18c406b1688db23a9799755a96bcddae446942c39681d071e51b32d519e4

Contents?: true

Size: 705 Bytes

Versions: 24

Compression:

Stored size: 705 Bytes

Contents

class Admin::ReddePhotosController < ActionController::Base
  def sort
    params[:photo].each_with_index do |id, idx|
      p = Redde::Photo.find(id)
      p.update(position: idx)
    end
    render nothing: true
  end

  def create
    parent = photo_params[:imageable_type].constantize.find(photo_params[:imageable_id])
    @photo = parent.photos.build(photo_params)
    if @photo.save
      render(partial: 'photo', object: @photo)
    else
      render nothing: true, status: 422
    end
  end

  def destroy
    @photo = Redde::Photo.find(params[:id])
    @photo.destroy
    render 'admin/redde_photos/destroy'
  end

  private

  def photo_params
    params.require(:redde_photo).permit!
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
redde-0.3.23 app/controllers/admin/redde_photos_controller.rb
redde-0.3.22 app/controllers/admin/redde_photos_controller.rb
redde-0.3.21 app/controllers/admin/redde_photos_controller.rb
redde-0.3.20 app/controllers/admin/redde_photos_controller.rb
redde-0.3.19 app/controllers/admin/redde_photos_controller.rb
redde-0.3.18 app/controllers/admin/redde_photos_controller.rb
redde-0.3.17 app/controllers/admin/redde_photos_controller.rb
redde-0.3.16 app/controllers/admin/redde_photos_controller.rb
redde-0.3.15 app/controllers/admin/redde_photos_controller.rb
redde-0.3.14 app/controllers/admin/redde_photos_controller.rb
redde-0.3.13 app/controllers/admin/redde_photos_controller.rb
redde-0.3.12 app/controllers/admin/redde_photos_controller.rb
redde-0.3.11 app/controllers/admin/redde_photos_controller.rb
redde-0.3.10 app/controllers/admin/redde_photos_controller.rb
redde-0.3.9 app/controllers/admin/redde_photos_controller.rb
redde-0.3.8 app/controllers/admin/redde_photos_controller.rb
redde-0.3.7 app/controllers/admin/redde_photos_controller.rb
redde-0.3.6 app/controllers/admin/redde_photos_controller.rb
redde-0.3.5 app/controllers/admin/redde_photos_controller.rb
redde-0.3.4 app/controllers/admin/redde_photos_controller.rb