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.3 app/controllers/admin/redde_photos_controller.rb
redde-0.3.2 app/controllers/admin/redde_photos_controller.rb
redde-0.3.1 app/controllers/admin/redde_photos_controller.rb
redde-0.3.0 app/controllers/admin/redde_photos_controller.rb