comparison app/controllers/pastes_controller.rb @ 4:23178d3de796

Slim controller (this app barely has any function)
author Edho Arief <edho@myconan.net>
date Sun, 26 Aug 2012 11:33:42 -0700
parents 42de15334db1
children 3a1f6c2e195d
comparison
equal deleted inserted replaced
3:04a43fae272c 4:23178d3de796
1 class PastesController < ApplicationController 1 class PastesController < ApplicationController
2 # GET /pastes
3 # GET /pastes.json
4 def index
5 @pastes = Paste.all
6
7 respond_to do |format|
8 format.html # index.html.erb
9 format.json { render :json => @pastes }
10 end
11 end
12
13 # GET /pastes/1 2 # GET /pastes/1
14 # GET /pastes/1.json 3 # GET /pastes/1.json
15 def show 4 def show
16 @paste = Paste.find(params[:id]) 5 @paste = Paste.find(params[:id])
17 6
30 format.html # new.html.erb 19 format.html # new.html.erb
31 format.json { render :json => @paste } 20 format.json { render :json => @paste }
32 end 21 end
33 end 22 end
34 23
35 # GET /pastes/1/edit
36 def edit
37 @paste = Paste.find(params[:id])
38 end
39
40 # POST /pastes 24 # POST /pastes
41 # POST /pastes.json 25 # POST /pastes.json
42 def create 26 def create
43 @paste = Paste.new 27 @paste = Paste.new
44 @paste.paste = params[:paste][:paste] 28 @paste.paste = params[:paste][:paste]
53 format.json { render :json => @paste.errors, :status => :unprocessable_entity } 37 format.json { render :json => @paste.errors, :status => :unprocessable_entity }
54 end 38 end
55 end 39 end
56 end 40 end
57 41
58 # PUT /pastes/1
59 # PUT /pastes/1.json
60 def update
61 @paste = Paste.find(params[:id])
62
63 respond_to do |format|
64 if @paste.update_attributes(params[:paste])
65 format.html { redirect_to @paste, :notice => 'Paste was successfully updated.' }
66 format.json { head :no_content }
67 else
68 format.html { render :action => "edit" }
69 format.json { render :json => @paste.errors, :status => :unprocessable_entity }
70 end
71 end
72 end
73
74 # DELETE /pastes/1
75 # DELETE /pastes/1.json
76 def destroy
77 @paste = Paste.find(params[:id])
78 @paste.destroy
79
80 respond_to do |format|
81 format.html { redirect_to pastes_url }
82 format.json { head :no_content }
83 end
84 end
85 end 42 end