class Warden::Manager
def serialize_from_session(scope = nil, &block)
Warden::Manager.serialize_from_session(:admin) { |id| AdminUser.get(id) }
# With Scope:
Warden::Manager.serialize_from_session{ |id| User.get(id) }
Example:
You can supply different methods of de-serialization for different scopes by passing a scope symbol
Use the results of user_session_key to reconstitute the user from the session on requests after the initial login
Reconstitutes the user from the session.
def serialize_from_session(scope = nil, &block) method_name = scope.nil? ? :deserialize : "#{scope}_deserialize" if Warden::SessionSerializer.method_defined? method_name Warden::SessionSerializer.send :remove_method, method_name end Warden::SessionSerializer.send :define_method, method_name, &block end