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