Method: CanCan::ControllerAdditions::ClassMethods#skip_load_resource

Defined in:
lib/cancan/controller_additions.rb

#skip_load_resource(*args) ⇒ Object

Skip the loading behavior of CanCan. This is useful when using load_and_authorize_resource but want to only do authorization on certain actions. You can pass :only and :except options to specify which actions to skip the effects on. It will apply to all actions by default.

class ProjectsController < ApplicationController
  load_and_authorize_resource
  skip_load_resource :only => :index
end

You can also pass the resource name as the first argument to skip that resource.



202
203
204
205
206
# File 'lib/cancan/controller_additions.rb', line 202

def skip_load_resource(*args)
  options = args.extract_options!
  name = args.first
  cancan_skipper[:load][name] = options
end