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