jcasimir/draper — Issue #64: UserDecorator.all returns an array of User not UserDecorator.  Rails 3.1
Author: anithri
Created: 2011-10-24 19:01:19+00:00
State: open

While trying to get ActiveScaffold to automatically load and use decorated objects, I tried to use ````UserDecorator.all``` which worked, but non-intuitively (to me at least) it returns an array of non-decorated objects, where I expected an array of decorated ones.

My workaround currently consists of

class User < ActiveRecord::Base
def decorated
@decorated ||= UserDecorator.new(self)
end
end

#used like
current_user.decorated.full_name

Which works perfectly well, except for the extra method call everywhere i want to use methods from the decorator.

I don't understand all of the ins and outs of the new Active Record relations that #all is part of, but shouldn't it be possible to add a .decorated type relation that just decorates each result upon return the values? I suspect that would be a better solution than just overriding #all, #find, #first, #last