1 class RentablePolicyController < ApplicationController
4 # Make sure that a user logs in before doing any action here
5 before_filter :authorize, :only => [:index, :list, :show]
7 # Make sure the user is a manager before doing any action specified
8 before_filter :manager, :only => [:new, :create, :edit, :update, :destroy]
12 render :action => 'list'
15 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
16 verify :method => :post, :only => [ :destroy, :create, :update ],
17 :redirect_to => { :action => :list }
20 @rentable_policy_pages, @rentable_policies = paginate :rentable_policies, :per_page => 10
24 @rentable_policy = RentablePolicy.find(params[:id])
28 @rentable_policy = RentablePolicy.new
32 @rentable_policy = RentablePolicy.new(params[:rentable_policy])
33 if @rentable_policy.save
34 flash[:notice] = 'RentablePolicy was successfully created.'
35 redirect_to :action => 'list'
37 render :action => 'new'
42 @rentable_policy = RentablePolicy.find(params[:id])
46 @rentable_policy = RentablePolicy.find(params[:id])
47 if @rentable_policy.update_attributes(params[:rentable_policy])
48 flash[:notice] = 'RentablePolicy was successfully updated.'
49 redirect_to :action => 'show', :id => @rentable_policy
51 render :action => 'edit'
56 RentablePolicy.find(params[:id]).destroy
57 redirect_to :action => 'list'