Decorating Sorcery's current_user with Draper
source link: https://www.devroom.io/2012/11/02/decorating_sorcery_current_user_with_draper/?utm_campaign=Feed%3A+ariejan+%28ariejan%7Cdevroom.io%29
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Decorating Sorcery's current_user with Draper
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.
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
Copyright © 1999-2020 Ariejan de Vroom <[email protected]>
Live now; make now always the most precious time. Now will never come again.
– Jean-Luc Picard
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK