Skip to main content

Decorating Sorcery's current_user with Draper

·71 words·1 min· ·
Ruby Rails Devise Draper Sorcery
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

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
end

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

Related

Decorating Devise's current_user with Draper
·102 words·1 min
Rails Devise Draper Decorators
Showing Ruby, Rails and git info in your app
·206 words·1 min
Ruby Rails Protip
Fast specs - Run your specs in less than 1 second
·1208 words·6 mins
Ruby Rails Rspec Testing Bdd Tdd Cucumber Fast_spec Fastspec Coreyhaines