1 class RentablePolicyController < ApplicationController
3 # Make sure that a user logs in before doing any action here
4 before_filter :authorize, :only => [:index, :list, :show]
6 # Make sure the user is a manager before doing any action specified
7 before_filter :manager, :only => [:new, :create, :edit, :update, :destroy]
11 render :action => 'list'
14 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
15 verify :method => :post, :only => [ :destroy, :create, :update ],
16 :redirect_to => { :action => :list }
19 @rentable_policy_pages, @rentable_policies = paginate :rentable_policies, :per_page => 10
23 @rentable_policy = RentablePolicy.find(params[:id])
27 @rentable_policy = RentablePolicy.new
31 @rentable_policy = RentablePolicy.new(params[:rentable_policy])
32 if @rentable_policy.save
33 flash[:notice] = 'RentablePolicy was successfully created.'
34 redirect_to :action => 'list'
36 render :action => 'new'
41 @rentable_policy = RentablePolicy.find(params[:id])
45 @rentable_policy = RentablePolicy.find(params[:id])
46 if @rentable_policy.update_attributes(params[:rentable_policy])
47 flash[:notice] = 'RentablePolicy was successfully updated.'
48 redirect_to :action => 'show', :id => @rentable_policy
50 render :action => 'edit'
55 RentablePolicy.find(params[:id]).destroy
56 redirect_to :action => 'list'