Basis of rails driven photo website with a Flash uploader
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

44 lines
846 B

  1. class PhotosController < ApplicationController
  2. def index
  3. @photos = Photo.all
  4. end
  5. def show
  6. @photo = Photo.find(params[:id])
  7. end
  8. def new
  9. @photo = Photo.new
  10. end
  11. def create
  12. @photo = Photo.new(params[:photo])
  13. if @photo.save
  14. flash[:notice] = "Successfully created photo."
  15. redirect_to @photo
  16. else
  17. render :action => 'new'
  18. end
  19. end
  20. def edit
  21. @photo = Photo.find(params[:id])
  22. end
  23. def update
  24. @photo = Photo.find(params[:id])
  25. if @photo.update_attributes(params[:photo])
  26. flash[:notice] = "Successfully updated photo."
  27. redirect_to @photo
  28. else
  29. render :action => 'edit'
  30. end
  31. end
  32. def destroy
  33. @photo = Photo.find(params[:id])
  34. @photo.destroy
  35. flash[:notice] = "Successfully destroyed photo."
  36. redirect_to photos_url
  37. end
  38. end