Add GamePlatform to Game pages
[cs356-p2-videostore.git] / app / controllers / game_platform_controller.rb
1 class GamePlatformController < ApplicationController
2   layout "admin"
3
4   def index
5     list
6     render :action => 'list'
7   end
8
9   # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
10   verify :method => :post, :only => [ :destroy, :create, :update ],
11          :redirect_to => { :action => :list }
12
13   def list
14     @game_platform_pages, @game_platforms = paginate :game_platforms, :per_page => 10
15   end
16
17   def show
18     @game_platform = GamePlatform.find(params[:id])
19   end
20
21   def new
22     @game_platform = GamePlatform.new
23   end
24
25   def create
26     @game_platform = GamePlatform.new(params[:game_platform])
27     if @game_platform.save
28       flash[:notice] = 'GamePlatform was successfully created.'
29       redirect_to :action => 'list'
30     else
31       render :action => 'new'
32     end
33   end
34
35   def edit
36     @game_platform = GamePlatform.find(params[:id])
37   end
38
39   def update
40     @game_platform = GamePlatform.find(params[:id])
41     if @game_platform.update_attributes(params[:game_platform])
42       flash[:notice] = 'GamePlatform was successfully updated.'
43       redirect_to :action => 'show', :id => @game_platform
44     else
45       render :action => 'edit'
46     end
47   end
48
49   def destroy
50     GamePlatform.find(params[:id]).destroy
51     redirect_to :action => 'list'
52   end
53 end