Skip to content

Instantly share code, notes, and snippets.

@radar
Created August 1, 2008 13:36
Show Gist options
  • Save radar/3623 to your computer and use it in GitHub Desktop.
Save radar/3623 to your computer and use it in GitHub Desktop.
# Add this line:
map.resources :teams
class TeamController < ApplicationController
def index
@teams = Team.find(:all)
end
def show
@team = Team.find(params[:id])
end
def new
@team = Team.new
end
def create
@team = Team.new(params[:team])
if @team.save
redirect_to teams_path
else
render :action => "new"
end
end
def edit
@team = Team.find(params[:id])
end
def update
@team = Team.find(params[:id])
if @team.update_attributes(params[:team])
redirect_to team_path(@team)
else
render :action => "edit"
end
end
def destroy
Team.find(params[:id]).destroy
redirect_to teams_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment