Sha256: 3aa955253edaa554ff2c5ef90b8008ca5c19142ca35dd367b23025e5135f7e56
Contents?: true
Size: 650 Bytes
Versions: 3
Compression:
Stored size: 650 Bytes
Contents
class Admin::PhotosController < ActionController::Base def sort params[:photo].each_with_index do |id, idx| p = Photo.find(id) p.position = idx p.save end render :nothing => true end def create if params[:product_id].present? @product = Product.find(params[:product_id]) @photo = @product.photos.build(src: params[:file]) end if @photo.save render layout: false else render js: 'alert("Ошибка! Фото не загружено")' end end def destroy @photo = Photo.find(params[:id]) @photo.destroy render 'admin/photos/destroy' end end
Version data entries
3 entries across 3 versions & 1 rubygems