Skip to content

Instantly share code, notes, and snippets.

@bitbckt
Created March 14, 2009 04:40
Show Gist options
  • Save bitbckt/78941 to your computer and use it in GitHub Desktop.
Save bitbckt/78941 to your computer and use it in GitHub Desktop.
class Admin::PlayersController < ApplicationController
before_filter :authenticate
before_filter :load_player, :except => [:index, :new, :create]
def index
@players = Player.all
end
def show
end
def new
@player = Player.new
end
def create
@player = Player.new(params[:player])
if @player.save
redirect_to admin_players_path
else
render :action => 'new'
end
end
def edit
end
def update
if @player.update_attributes(params[:player])
redirect_to admin_player_path(@player)
else
render :action => 'edit'
end
end
def destroy
@player.destroy
redirect_to admin_players_path
end
private
def load_player
@player = Player.find(params[:id])
rescue ActiveRecord::RecordNotFound
flash[:error] = 'Player not found.'
redirect_to admin_players_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment