X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=app%2Fcontrollers%2Fvideo_policy_controller.rb;fp=app%2Fcontrollers%2Fvideo_policy_controller.rb;h=4be73daaa6fdb825c2dfcaf72015659d2229178c;hb=01114330b962728805d3c43f2f1a1423f2bd66b3;hp=0000000000000000000000000000000000000000;hpb=09ddd1ef5546ec679c832c7cefb93f00125c96c6;p=cs356-p2-videostore.git diff --git a/app/controllers/video_policy_controller.rb b/app/controllers/video_policy_controller.rb new file mode 100644 index 0000000..4be73da --- /dev/null +++ b/app/controllers/video_policy_controller.rb @@ -0,0 +1,51 @@ +class VideoPolicyController < ApplicationController + def index + list + render :action => 'list' + end + + # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) + verify :method => :post, :only => [ :destroy, :create, :update ], + :redirect_to => { :action => :list } + + def list + @video_policy_pages, @video_policies = paginate :video_policies, :per_page => 10 + end + + def show + @video_policy = VideoPolicy.find(params[:id]) + end + + def new + @video_policy = VideoPolicy.new + end + + def create + @video_policy = VideoPolicy.new(params[:video_policy]) + if @video_policy.save + flash[:notice] = 'VideoPolicy was successfully created.' + redirect_to :action => 'list' + else + render :action => 'new' + end + end + + def edit + @video_policy = VideoPolicy.find(params[:id]) + end + + def update + @video_policy = VideoPolicy.find(params[:id]) + if @video_policy.update_attributes(params[:video_policy]) + flash[:notice] = 'VideoPolicy was successfully updated.' + redirect_to :action => 'show', :id => @video_policy + else + render :action => 'edit' + end + end + + def destroy + VideoPolicy.find(params[:id]).destroy + redirect_to :action => 'list' + end +end