Please read for an updated status on RailsCasts:
Learn more or hide this
GitHub User: TylerRick
Since I've started using Draper, I've generally been pretty happy with it. The one thing that keeps biting me is object equality (decorated_object != object) and in general code that expects to be dealing with an actual instance of the model class and not an instance of the decorator behaves differently or incorrectly when your object isn't actually an instance of your model class.
decorated_object != object
If @user is a UserDecorator object and current_user is a User object, for example, then even a simple test like this:
if @user == current_user
doesn't work as expected.
Have also had some occasional odd behavior when working with CanCan. (To get error messages to work as expected, for example I had to add a section for user_decorator: in addition to user: in my locale file because it looks up messages based on the object's class.)
I wish Draper worked by mixing in a module instead of creating a an entirely new class. Then a decorated User object, for example, would still be a User and object equality would work as expected.
But I guess Draper was only intended to be used in the view layer, so my mistake was probably that I am decorating objects in the controller as soon as I fetch them from the database. Maybe I will try to only create and use the decorated objects in the view and see if that works any better...