Class: IshManager::PhotosController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::PhotosController
- Defined in:
- app/controllers/ish_manager/photos_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#destroy ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/ish_manager/photos_controller.rb', line 12 def destroy @photo = Photo.unscoped.find params[:id] :destroy, @photo @photo.gallery.touch if @photo.gallery @photo.is_trash = true flag = @photo.save if flag flash[:notice] = "Success" else flash[:alert] = "No luck: #{@photo.errors.}" end redirect_to request.referrer || root_path end |
#j_create ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/ish_manager/photos_controller.rb', line 31 def j_create # find this gallery if params[:galleryname] gallery = Gallery.unscoped.where( :galleryname => params[:galleryname] ).first gallery ||= Gallery.unscoped.find params[:galleryname] elsif params[:gallery_id] # this one, let's normalize on id everywhere in manager. gallery = Gallery.unscoped.find( params[:gallery_id] ) gallery ||= Gallery.unscoped.where( :galleryname => params[:gallery_id] ).first end :create_photo, gallery @photo = Photo.new params[:photo].permit! @photo.is_public = true @photo.gallery = gallery # cache @photo.gallery.site.touch if @photo.gallery.site @photo.gallery.city.touch if @photo.gallery.city @photo.gallery.touch if @photo.save j = { :name => @photo.photo.original_filename, :size => @photo.photo.size, :url => @photo.photo.url( :large ), :thumbnail_url => @photo.photo.url( :thumb ), :delete_url => photo_path(@photo), :delete_type => 'DELETE' } render :json => [ j ] else render :json => { "errors" => @photo.errors } end end |
#show ⇒ Object
26 27 28 29 |
# File 'app/controllers/ish_manager/photos_controller.rb', line 26 def show @photo = Photo.unscoped.find params[:id] :show, @photo end |
#without_gallery ⇒ Object
8 9 10 |
# File 'app/controllers/ish_manager/photos_controller.rb', line 8 def without_gallery @photos = Photo.unscoped.where( :gallery => nil, :is_trash => false ) end |