2
|
1 class PastesController < ApplicationController
|
|
2 # GET /pastes/1
|
|
3 # GET /pastes/1.json
|
|
4 def show
|
|
5 @paste = Paste.find(params[:id])
|
|
6
|
|
7 respond_to do |format|
|
|
8 format.html # show.html.erb
|
7
|
9 format.txt # show.html.erb
|
2
|
10 format.json { render :json => @paste }
|
|
11 end
|
|
12 end
|
|
13
|
|
14 # GET /pastes/new
|
|
15 # GET /pastes/new.json
|
|
16 def new
|
|
17 @paste = Paste.new
|
10
|
18 begin
|
|
19 @paste.paste = Paste.find(params[:base]).paste
|
|
20 rescue
|
|
21 nil
|
|
22 end
|
2
|
23
|
|
24 respond_to do |format|
|
|
25 format.html # new.html.erb
|
|
26 format.json { render :json => @paste }
|
|
27 end
|
|
28 end
|
|
29
|
|
30 # POST /pastes
|
|
31 # POST /pastes.json
|
|
32 def create
|
|
33 @paste = Paste.new
|
|
34 @paste.paste = params[:paste][:paste]
|
|
35 @paste.ip = request.remote_ip
|
|
36
|
|
37 respond_to do |format|
|
|
38 if @paste.save
|
|
39 format.html { redirect_to @paste, :notice => 'Paste was successfully created.' }
|
|
40 format.json { render :json => @paste, :status => :created, :location => @paste }
|
|
41 else
|
|
42 format.html { render :action => "new" }
|
|
43 format.json { render :json => @paste.errors, :status => :unprocessable_entity }
|
|
44 end
|
|
45 end
|
|
46 end
|
|
47
|
|
48 end
|