Basis of rails-driven app for local business
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
869 B

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