Issue calling find on a collection decorator since version 1.2.0 #509

mattbeedle opened this Issue Apr 4, 2013 · 3 comments


None yet

3 participants

=> #<Project id: 1, ....>

NoMethodError: undefined method `find' for nil:NilClass

Seems that the decorator_class isn't being set anymore.


I can take a closer look and provide a patch after the weekend if no one else gets to it first

drapergem member

The reason decorator_class isn't set here is for STI support; since it's nil, the decorator is inferred for each item.

I would just use some_scope.find(1).decorate rather than some_scope.decorate.find(1)

Apart from being inconsistent with our general policy of not supporting queries on collection decorators, I think this functionality is actually quite broken: user.projects.decorate.find(1) returns project 1 even if it does not belong to the user in question.

I suggest we fix it but also deprecate it.

drapergem member

I suggest we fix it but also deprecate it.

Seems good. Let's leave this open until that's done.

@haines haines added a commit that closed this issue Apr 5, 2013
@haines haines Fix `CollectionDecorator#find`
Deprecates the use of ActiveRecord's `find` method on a collection

Closes #509
@haines haines closed this in 29590a5 Apr 5, 2013
@seanlinsley seanlinsley added a commit to activeadmin/activeadmin that referenced this issue Oct 11, 2015
@seanlinsley seanlinsley #3930 forces deprecation warnings to cause test failures, so we're
forced to fix them. This is one deprecation:

>DEPRECATION WARNING: Using ActiveRecord's `find` on a
CollectionDecorator is deprecated. Call `find` on a model, and then
decorate the result. (called from block in add_default_batch_action at
lib/active_admin/batch_actions/resource_extension.rb:73) (StandardError)

This issue was introduced by #3775, which started decorating
collections for batch actions. The Draper ticket that resulted in the
deprecation is: drapergem/draper#509.

The simple solution would be to no longer decorate the batch action
collections, which is what this commit does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment