Sha256: c8123a5efef621845ed7c40fba7451f9955f194e198d0d43b5c9d840e8448475
Contents?: true
Size: 816 Bytes
Versions: 21
Compression:
Stored size: 816 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 if photo_params[:imageable_id].present? parent = photo_params[:imageable_type].constantize.find(photo_params[:imageable_id]) @photo = parent.photos.build(photo_params) else @photo = Redde::Photo.new(photo_params) end 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
21 entries across 21 versions & 1 rubygems