Mercurial > zeropaste
comparison app/controllers/pastes_controller.rb @ 74:48598fc65c20
Fixed comments on pastes_controller.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Thu, 04 Oct 2012 11:00:58 +0700 |
parents | f480cdf5f3df |
children | 8f6a0204b2a7 |
comparison
equal
deleted
inserted
replaced
73:f480cdf5f3df | 74:48598fc65c20 |
---|---|
1 class PastesController < ApplicationController | 1 class PastesController < ApplicationController |
2 caches_page :show | 2 caches_page :show |
3 | 3 |
4 # GET /pastes/1 | 4 # GET /1 |
5 # GET /pastes/1.json | 5 # GET /1.txt |
6 def show | 6 def show |
7 id = params[:id].to_i | 7 id = params[:id].to_i |
8 if id.to_s != params[:id] | 8 if id.to_s != params[:id] |
9 redirect_to paste_path(id) | 9 redirect_to paste_path(id) |
10 return | 10 return |
11 end | 11 end |
12 @paste = Paste.find(params[:id]) | 12 @paste = Paste.find(params[:id]) |
13 | 13 |
14 respond_to do |format| | 14 respond_to do |format| |
15 format.html # show.html.erb | 15 format.html # show.html.erb |
16 format.txt # show.html.erb | 16 format.txt # show.txt.erb |
17 end | 17 end |
18 end | 18 end |
19 | 19 |
20 # GET /pastes/new | 20 # GET / |
21 # GET /pastes/new.json | |
22 def new | 21 def new |
23 @paste = Paste.new | 22 @paste = Paste.new |
24 begin | 23 begin |
25 @paste.paste = Paste.find(params[:base]).paste | 24 @paste.paste = Paste.find(params[:base]).paste |
26 rescue | 25 rescue |
30 format.html # new.html.erb | 29 format.html # new.html.erb |
31 format.json { render :json => @paste } | 30 format.json { render :json => @paste } |
32 end | 31 end |
33 end | 32 end |
34 | 33 |
35 # POST /pastes | 34 # POST / |
36 # POST /pastes.json | 35 # POST /pastes.json |
36 # POST /pastes.txt | |
37 def create | 37 def create |
38 @paste = Paste.new | 38 @paste = Paste.new |
39 if params[:paste] and not params[:paste][:paste].blank? | 39 if params[:paste] and not params[:paste][:paste].blank? |
40 @paste.paste = params[:paste][:paste] | 40 @paste.paste = params[:paste][:paste] |
41 @paste.ip = request.remote_ip | 41 @paste.ip = request.remote_ip |