Skip to content

Instantly share code, notes, and snippets.

@bonkydog
Created November 6, 2009 06:22
Show Gist options
  • Save bonkydog/227772 to your computer and use it in GitHub Desktop.
Save bonkydog/227772 to your computer and use it in GitHub Desktop.
class ThingsController < ApplicationController
# GET /things
def index
@things = Thing.all
end
# GET /things/1
def show
@thing = Thing.find(params[:id])
end
# GET /things/new
def new
@thing = Thing.new
end
# GET /things/1/edit
def edit
@thing = Thing.find(params[:id])
end
# POST /things
def create
@thing = Thing.new(params[:thing])
if @thing.save
flash[:notice] = 'Thing was successfully created.'
redirect_to(@thing)
else
render :action => "new"
end
end
# PUT /things/1
def update
@thing = Thing.find(params[:id])
if @thing.update_attributes(params[:thing])
flash[:notice] = 'Thing was successfully updated.'
redirect_to(@thing)
else
render :action => "edit"
end
end
# DELETE /things/1
def destroy
@thing = Thing.find(params[:id])
@thing.destroy
redirect_to(things_url)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment