annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
1 class PastesController < ApplicationController
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
2 # GET /pastes/1
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
3 # GET /pastes/1.json
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
4 def show
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
5 @paste = Paste.find(params[:id])
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
6
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
7 respond_to do |format|
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
8 format.html # show.html.erb
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
9 format.json { render :json => @paste }
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
10 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
11 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
12
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
13 # GET /pastes/new
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
14 # GET /pastes/new.json
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
15 def new
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
16 @paste = Paste.new
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
17
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
18 respond_to do |format|
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
19 format.html # new.html.erb
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
20 format.json { render :json => @paste }
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
21 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
22 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
23
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
24 # POST /pastes
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
25 # POST /pastes.json
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
26 def create
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
27 @paste = Paste.new
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
28 @paste.paste = params[:paste][:paste]
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
29 @paste.ip = request.remote_ip
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
30
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
31 respond_to do |format|
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
32 if @paste.save
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
33 format.html { redirect_to @paste, :notice => 'Paste was successfully created.' }
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
34 format.json { render :json => @paste, :status => :created, :location => @paste }
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
35 else
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
36 format.html { render :action => "new" }
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
37 format.json { render :json => @paste.errors, :status => :unprocessable_entity }
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
38 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
39 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
40 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
41
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
42 end