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