Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. class ClocksController < ApplicationController
  2. # GET /clocks
  3. # GET /clocks.xml
  4. def index
  5. @clocks = current_user.clocks.all
  6.  
  7. respond_to do |format|
  8. format.html # index.html.erb
  9. format.xml { render :xml => @clocks }
  10. end
  11. end
  12.  
  13. # GET /clocks/1
  14. # GET /clocks/1.xml
  15. def show
  16. @clock = current_user.clocks.find(params[:id])
  17.  
  18. respond_to do |format|
  19. format.html # show.html.erb
  20. format.xml { render :xml => @clock }
  21. end
  22. end
  23.  
  24. # GET /clocks/new
  25. # GET /clocks/new.xml
  26. def new
  27. @clock = current_user.clocks.new
  28.  
  29. respond_to do |format|
  30. format.html # new.html.erb
  31. format.xml { render :xml => @clock }
  32. end
  33. end
  34.  
  35. # GET /clocks/1/edit
  36. def edit
  37. @clock = current_user.clocks.find(params[:id])
  38. end
  39.  
  40. # POST /clocks
  41. # POST /clocks.xml
  42. def create
  43. @clock = current_user.clocks.new(params[:clock])
  44.  
  45. respond_to do |format|
  46. if @clock.save
  47. format.html { redirect_to(@clock, :notice => 'Clock was successfully created.') }
  48. format.xml { render :xml => @clock, :status => :created, :location => @clock }
  49. else
  50. format.html { render :action => "new" }
  51. format.xml { render :xml => @clock.errors, :status => :unprocessable_entity }
  52. end
  53. end
  54. end
  55.  
  56. # PUT /clocks/1
  57. # PUT /clocks/1.xml
  58. def update
  59. @clock = current_user.clocks.find(params[:id])
  60.  
  61. respond_to do |format|
  62. if @clock.update_attributes(params[:clock])
  63. format.html { redirect_to(@clock, :notice => 'Clock was successfully updated.') }
  64. format.xml { head :ok }
  65. else
  66. format.html { render :action => "edit" }
  67. format.xml { render :xml => @clock.errors, :status => :unprocessable_entity }
  68. end
  69. end
  70. end
  71.  
  72. # DELETE /clocks/1
  73. # DELETE /clocks/1.xml
  74. def destroy
  75. @clock = current_user.clocks.find(params[:id])
  76. @clock.destroy
  77.  
  78. respond_to do |format|
  79. format.html { redirect_to(clocks_url) }
  80. format.xml { head :ok }
  81. end
  82. end
  83. end
Add Comment
Please, Sign In to add comment