Skip to content

Instantly share code, notes, and snippets.

@denvazh
Created June 20, 2016 05:13
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 denvazh/f029c3d83c2505ab53294e7fa133670f to your computer and use it in GitHub Desktop.
Save denvazh/f029c3d83c2505ab53294e7fa133670f to your computer and use it in GitHub Desktop.
Use email instead of confirmation token in Devise model (mainly used during stress testing)
unless Rails.env.test?
module Devise
module Models
module Confirmable
module ClassMethods
# Use email instead of confirmation_token, i.e. if user exist it will be confirmed
def confirm_by_token(email)
user_confirmable = find_first_by_auth_conditions(email: email)
unless user_confirmable
user_confirmable = find_or_initialize_with_error_by(:email, email)
end
user_confirmable.confirm if user_confirmable.persisted?
user_confirmable
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment