Created
March 14, 2009 04:40
-
-
Save bitbckt/78941 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 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