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