Class: PhotosManager::PhotosController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/photos_manager/photos_controller.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/controllers/photos_manager/photos_controller.rb', line 12

def create
  @photo = @event.photos.new(:image => params[:Filedata])
  @photos = Kaminari.paginate_array(@event.photos).page(params[:page]).per(12) 
  unless @photo.save
    flash[:error] = "La photo n'a pas pu être téléchargée.".html_safe
  end
  render :partial => 'listing', :locals => { :photos => @photos}
end

#destroy ⇒ Object



21
22
23
24
25
26
# File 'app/controllers/photos_manager/photos_controller.rb', line 21

def destroy
  photo = Photo.find(params[:id])
  photo.destroy
  @photos = Kaminari.paginate_array(@event.photos).page(params[:page]).per(12) 
  render :partial => 'listing', :locals => { :photos => @photos }
end

#index ⇒ Object



6
7
8
9
10
# File 'app/controllers/photos_manager/photos_controller.rb', line 6

def index
  @photo = Photo.find(params[:id])
  @photos = @photo.event.photos
  render :partial => 'carousel', :locals => {:photos => @photos, :current => @photo}
end