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
|
|
18
|
|
19 respond_to do |format|
|
|
20 format.html # new.html.erb
|
|
21 format.json { render :json => @paste }
|
|
22 end
|
|
23 end
|
|
24
|
|
25 # POST /pastes
|
|
26 # POST /pastes.json
|
|
27 def create
|
|
28 @paste = Paste.new
|
|
29 @paste.paste = params[:paste][:paste]
|
|
30 @paste.ip = request.remote_ip
|
|
31
|
|
32 respond_to do |format|
|
|
33 if @paste.save
|
|
34 format.html { redirect_to @paste, :notice => 'Paste was successfully created.' }
|
|
35 format.json { render :json => @paste, :status => :created, :location => @paste }
|
|
36 else
|
|
37 format.html { render :action => "new" }
|
|
38 format.json { render :json => @paste.errors, :status => :unprocessable_entity }
|
|
39 end
|
|
40 end
|
|
41 end
|
|
42
|
|
43 end
|