Created
July 20, 2012 02:36
-
-
Save khoan/3148305 to your computer and use it in GitHub Desktop.
Devise Authentication unscoped
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/devise.rb | |
# | |
# We now ask Warden to use :vip_authenticatable when authenticating. | |
# | |
# Also, we instruct Warden to load User from session without any default scoping. | |
# | |
Devise.setup do |config| | |
config.warden do |manager| | |
require Rails.root+'lib/vip_authenticable' | |
manager.default_strategies(scope: :user).unshift :vip_authenticatable | |
manager.serialize_from_session do |keys| | |
klass, *args = keys | |
user = ActiveSupport::Inflector.constantize(klass).unscoped.serialize_from_session(*args) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another way: http://stackoverflow.com/a/24990576/464685 in case you need that specifically for a single model.