Created
November 6, 2009 06:22
-
-
Save bonkydog/227772 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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