devroom.io/drafts/2012-11-02-decorating_sorcery_current_user_with_draper.md
Ariejan de Vroom dbae98c4c0 Moar updates
2013-03-24 14:27:51 +01:00

967 B

title kind slug created_at tags
Decorating Sorcery's current_user with Draper article decorating_sorcery_current_user_with_draper 2012-11-02
Ruby
Rails
devise
draper
sorcery

I already wrote about how to apply your decorator to the current_user when you're using Devise. However, the trick is a bit different when applied to Sorcery.

Instead of being nil when no user is signed in, Sorcery uses an explicit false value, no nil. In your ApplicationController at app/controllers/application_controller.rb add this:

:::ruby
def current_user
  UserDecorator.decorate(super) unless super == false
end

I'm using the most recent version of Draper by the way.