Class: Wco::PhotosController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Wco::PhotosController
- Defined in:
- app/controllers/wco/photos_controller.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
Alphabetized : ).
- #index ⇒ Object
- #j_create ⇒ Object
- #move ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #without_gallery ⇒ Object
Instance Method Details
#destroy ⇒ Object
Alphabetized : )
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/wco/photos_controller.rb', line 10 def destroy :destroy, Wco::Photo if params[:id] @photos = [ Wco::Photo.unscoped.find( params[:id] ) ] elsif params[:ids] @photos = Wco::Photo.where( :id.in => params[:ids] ) end outs = [] @photos.map do |photo| photo.gallery.touch if photo.gallery outs.push photo.delete end flash_notice "Outcomes: #{outs}" redirect_to request.referrer || root_path end |
#index ⇒ Object
26 27 28 29 |
# File 'app/controllers/wco/photos_controller.rb', line 26 def index :index, Wco::Photo @photos = Wco::Photo.where( user_profile: @current_profile ).page( params[:photos_page] ) 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 |
# File 'app/controllers/wco/photos_controller.rb', line 31 def j_create if params[:slug] gallery = Wco::Gallery.unscoped.where( :slug => params[:slug] ).first gallery ||= Wco::Gallery.unscoped.find params[:slug] elsif params[:gallery_id] gallery = Wco::Gallery.unscoped.find( params[:gallery_id] ) gallery ||= Wco::Gallery.unscoped.where( :slug => params[:gallery_id] ).first end :create_photo, gallery @photo = Wco::Photo.new params[:photo].permit! @photo.is_public = true @photo.gallery = gallery @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 => { message: @photo.errors..join(", "), filename: @photo.photo.original_filename, }, status: 400 end end |
#move ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/wco/photos_controller.rb', line 65 def move :move, Wco::Photo photos = Wco::Photo.where({ :id.in => params[:ids] }) if params['delete'] == '1' flash_notice 'deleting' flag = photos.map &:delete else flag = photos.update_all({ gallery_id: params[:gallery_id] }) flash_notice 'moving' end flash_notice flag redirect_to request.referrer end |
#new ⇒ Object
80 81 82 83 |
# File 'app/controllers/wco/photos_controller.rb', line 80 def new :new, Wco::Photo @photo = Wco::Photo.new end |