Add the Gameplatform MVC to handle the different game platforms
[cs356-p2-videostore.git] / app / controllers / gameplatform_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     @gameplatform_pages, @gameplatforms = paginate :gameplatforms, :per_page => 10
13   end
14
15   def show
16     @gameplatform = Gameplatform.find(params[:id])
17   end
18
19   def new
20     @gameplatform = Gameplatform.new
21   end
22
23   def create
24     @gameplatform = Gameplatform.new(params[:gameplatform])
25     if @gameplatform.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     @gameplatform = Gameplatform.find(params[:id])
35   end
36
37   def update
38     @gameplatform = Gameplatform.find(params[:id])
39     if @gameplatform.update_attributes(params[:gameplatform])
40       flash[:notice] = 'Gameplatform was successfully updated.'
41       redirect_to :action => 'show', :id => @gameplatform
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