adding :through_association option to load_resource (thanks hunterae) - closes #171
This commit is contained in:
@@ -71,6 +71,10 @@ module CanCan
|
||||
# [:+through+]
|
||||
# Load this resource through another one. This should match the name of the parent instance variable or method.
|
||||
#
|
||||
# [:+through_association+]
|
||||
# The name of the association to fetch the child records through the parent resource. This is normally not needed
|
||||
# because it defaults to the pluralized resource name.
|
||||
#
|
||||
# [:+shallow+]
|
||||
# Pass +true+ to allow this resource to be loaded directly when parent is +nil+. Defaults to +false+.
|
||||
#
|
||||
|
||||
@@ -136,7 +136,7 @@ module CanCan
|
||||
def resource_base
|
||||
if @options[:through]
|
||||
if parent_resource
|
||||
@options[:singleton] ? parent_resource : parent_resource.send(name.to_s.pluralize)
|
||||
@options[:singleton] ? parent_resource : parent_resource.send(@options[:through_association] || name.to_s.pluralize)
|
||||
elsif @options[:shallow]
|
||||
resource_class
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user