Skip to content
Extraits de code Groupes Projets
photos_controller.rb 712 octets
Newer Older
  • Learn to ignore specific revisions
  • Raphael's avatar
    Raphael a validé
    class PhotosController < ApplicationController
    
      before_filter :authenticate_user!
    
    Raphael's avatar
    Raphael a validé
    
      def index
        @photos = Photo.paginate :page => params[:page], :order => 'created_at DESC'
      end
      
      def create
        @photo = Photo.new(params[:photo])
    
    Raphael's avatar
    Raphael a validé
        if @photo.save
          flash[:notice] = "Successfully uploaded photo."
          redirect_to photos_url
        else
          render :action => 'new'
        end
      end
      
      def new
        @photo = Photo.new
      end
      
      def destroy
        @photo = Photo.where(:id => params[:id]).first
        @photo.destroy
        flash[:notice] = "Successfully deleted photo."
        redirect_to root_url
      end
      
      def show
        @photo = Photo.where(:id => params[:id]).first
      end
    end