Skip to content

Instantly share code, notes, and snippets.

@Breefield
Created October 23, 2013 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Breefield/7110720 to your computer and use it in GitHub Desktop.
Save Breefield/7110720 to your computer and use it in GitHub Desktop.
class UserSession < Authlogic::Session::Base
validate :check_presence
# Without the following method, calling persisted? on UserSession fails,
# which is needed for polymorphic_url when called with a UserSession.
def destroyed?
false
end
private
# If neither email nor password are present, Authlogic adds an error to
# :base, but not either field.
def check_presence
if !email && !password
errors.add(:email, 'cannot be blank')
errors.add(:password, 'cannot be blank')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment