Sha256: 461c440af5a6180b135eccc27d9b85d13bbdcb400b99802193f23502809f764d

Contents?: true

Size: 566 Bytes

Versions: 11

Compression:

Stored size: 566 Bytes

Contents

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

  def create
    parent = Product.find(params[:product_id]) if params[:product_id].present?
    @photo = parent.photos.build(src: params[:file])
    render js: 'alert("Ошибка! Фото не загружено")' unless @photo.save
  end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
redde-0.1.18 lib/generators/redde/photo/templates/controller.rb
redde-0.1.17 lib/generators/redde/photo/templates/controller.rb
redde-0.1.16 lib/generators/redde/photo/templates/controller.rb
redde-0.1.15 lib/generators/redde/photo/templates/controller.rb
redde-0.1.14 lib/generators/redde/photo/templates/controller.rb
redde-0.1.13 lib/generators/redde/photo/templates/controller.rb
redde-0.1.12 lib/generators/redde/photo/templates/controller.rb
redde-0.1.11 lib/generators/redde/photo/templates/controller.rb
redde-0.1.10 lib/generators/redde/photo/templates/controller.rb
redde-0.1.9 lib/generators/redde/photo/templates/controller.rb
redde-0.1.8 lib/generators/redde/photo/templates/controller.rb