module Devise::Models::Confirmable::ClassMethods

def confirm_by_token(confirmation_token)

Options must have the confirmation_token
If the user is already confirmed, create an error for the user
If no user is found, returns a new user with an error.
Find a user by it's confirmation token and try to confirm it.
def confirm_by_token(confirmation_token)
  confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
  confirmable.confirm! unless confirmable.new_record?
  confirmable
end