Search code examples
ruby-on-railsdevisedevise-confirmable

How to conditionally ignore that a user is not confirmed in Rails, Devise?


Basically what I have is that a user is created upon a booking (from their booking details), but they have to tick an option to actually have an account on the website. The latter type of user needs confirmation of email, but the previous - does not.

How do I ignore that a user is not confirmed dynamically based on some model attribute?


Solution

  • You can use skip_confirmation_notification! from the Confirmable module.

    This would create the user but wouldn't send them a confirmation email. It would still require being confirmed for the user to become a devise user, but you can still retrieve the user using either the user.confirmation_token which would eq a unique token (NULL for confirmed users), or the user.confirmed_at would be NULL for non confirms, as a date is added when confirmed.