Search code examples
ruby-on-railsruby-on-rails-3devisedevise-confirmable

Using confirmable(devise) module after sign-up


I am using confirmable in one of the user models , however the idea is different here . The user isn't required to confirm his account on the time of sign-up , he can confirm it later by clicking on confirm .I have read the devise documentation but didn't found any part suitable to my scenario . Can anyone please provide any links or suggestions for the same . Thanks in advance :)

Update -

The user will be able to login into his account and do all kinds of operations without confirming his e-mail . But confirming his mail would add a tag named confirmed to his account . This is what i am trying to do .


Solution

  • I think you can do what you want by setting allow_unconfirmed_access_for to nil in your devise.rb initialiser:

    config.allow_unconfirmed_access_for = nil
    

    The confirmation email will still be sent, but they will not be required to click on the link before being able to log in. They can click the link at any time in the future and when they do, the confirmed_at time in their user record will be set and user.confirmed? will then returntrue`.

    Make sure you haven't set confirm_within in your devise.rb initialiser, or if it is there, make sure it's nil. I don't think it's in there by default, but might be worth checking if you have trouble.

    UPDATE

    As you don't want to send the email, you need to call skip_confirmation_notification! during your signup process and also if they can edit their email address and you are using reconfirmable. This means that the email won't be sent, but the account will still need confirmation. However, because you've set allow_unconfirmed_access_for to nil, it won't be necessary. Then you could provide a button or something on your site when they're logged in to let them send the email and when it's clicked you'd need to call current_user.send_confirmation_instructions.