Decorating Sorcery's current_user with Draper

| Posted: - Last updated:
| Tagged ruby rails devise draper sorcery
| ~100wrds (~1min)

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:

def current_user
  UserDecorator.decorate(super) unless super == false

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

My site is free of ads and trackers. I record privacy-respecting usage statistics with Fathom.

Was this post helpful to you? Why not ☕ Buy me a coffee or use Brave Browser to send a tip.