load_collection? triggers sql query on inherited resources #813

Open
wants to merge 1 commit into from
View
6 lib/cancan/controller_resource.rb
@@ -74,7 +74,11 @@ def load_instance?
end
def load_collection?
- resource_base.respond_to?(:accessible_by) && !current_ability.has_block?(authorization_action, resource_class)
+ if @options[:through]

Does this need to be something like: if @options[:through] && parent_resource instead to avoid raising when resource_base resolves to the resource_class when @options[:shallow] is true?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ resource_base.proxy_association.klass
+ else
+ resource_base
+ end.respond_to?(:accessible_by) && !current_ability.has_block?(authorization_action, resource_class)
end
def load_collection