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
928 B

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