Class: CanCan::InheritedResource

Inherits:
ControllerResource show all
Defined in:
lib/cancan/inherited_resource.rb

Overview

For use with Inherited Resources

Instance Method Summary collapse

Methods inherited from ControllerResource

add_before_filter, #authorize_resource, #initialize, #load_and_authorize_resource, #load_resource, #parent?, #skip?

Constructor Details

This class inherits a constructor from CanCan::ControllerResource

Instance Method Details

#load_resource_instanceObject

:nodoc:



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/cancan/inherited_resource.rb', line 4

def load_resource_instance
  if parent?
    @controller.send :association_chain
    @controller.instance_variable_get("@#{instance_name}")
  elsif new_actions.include? @params[:action].to_sym
    resource = @controller.send :build_resource
    assign_attributes(resource)
  else
    @controller.send :resource
  end
end

#resource_baseObject



16
17
18
# File 'lib/cancan/inherited_resource.rb', line 16

def resource_base
  @controller.send :end_of_association_chain
end