changeset 4:23178d3de796

Slim controller (this app barely has any function)
author Edho Arief <edho@myconan.net>
date Sun, 26 Aug 2012 11:33:42 -0700
parents 04a43fae272c
children fe0cb4276ae7
files app/controllers/pastes_controller.rb config/routes.rb
diffstat 2 files changed, 3 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/pastes_controller.rb	Sun Aug 26 11:29:31 2012 -0700
+++ b/app/controllers/pastes_controller.rb	Sun Aug 26 11:33:42 2012 -0700
@@ -1,15 +1,4 @@
 class PastesController < ApplicationController
-  # GET /pastes
-  # GET /pastes.json
-  def index
-    @pastes = Paste.all
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render :json => @pastes }
-    end
-  end
-
   # GET /pastes/1
   # GET /pastes/1.json
   def show
@@ -32,11 +21,6 @@
     end
   end
 
-  # GET /pastes/1/edit
-  def edit
-    @paste = Paste.find(params[:id])
-  end
-
   # POST /pastes
   # POST /pastes.json
   def create
@@ -55,31 +39,4 @@
     end
   end
 
-  # PUT /pastes/1
-  # PUT /pastes/1.json
-  def update
-    @paste = Paste.find(params[:id])
-
-    respond_to do |format|
-      if @paste.update_attributes(params[:paste])
-        format.html { redirect_to @paste, :notice => 'Paste was successfully updated.' }
-        format.json { head :no_content }
-      else
-        format.html { render :action => "edit" }
-        format.json { render :json => @paste.errors, :status => :unprocessable_entity }
-      end
-    end
-  end
-
-  # DELETE /pastes/1
-  # DELETE /pastes/1.json
-  def destroy
-    @paste = Paste.find(params[:id])
-    @paste.destroy
-
-    respond_to do |format|
-      format.html { redirect_to pastes_url }
-      format.json { head :no_content }
-    end
-  end
 end
--- a/config/routes.rb	Sun Aug 26 11:29:31 2012 -0700
+++ b/config/routes.rb	Sun Aug 26 11:33:42 2012 -0700
@@ -1,5 +1,7 @@
 Zeropaste::Application.routes.draw do
-  resources :pastes
+  resources :pastes, :only => [:show, :new, :create]
+  get '/:id' => 'pastes#show', :constraints => { :id => /\d+/ }
+  root :to => 'pastes#new'
 
   # The priority is based upon order of creation:
   # first created -> highest priority.