I'm using Devise for authentication in my application. I don't want to require email confirmation when a user signs up, but I do want to require it if the user wants the app to send them email updates. Is this possible with the built-in :confirmable feature of Devise? I found the setting to set how long a user can log in without confirming, but I essentially want to set that to "forever".
Asked
Active
Viewed 762 times
2 Answers
1
Check out https://github.com/plataformatec/devise/blob/master/lib/devise/models/confirmable.rb. You can probably override confirmation_period_valid?
by returning always true
.
Alternatively, maybe you can change your setting to something like 10000.years.from_now
, which might be a good enough estimation for "forever", perhaps?

Benjamin Tan Wei Hao
- 9,621
- 3
- 30
- 56
-
Would I do that by just adding that method to my User model? – dpassage Oct 13 '12 at 03:39
-
Yes, I thought about the `10000.years` solution, but it seemed like I should be able to do something cleaner. – dpassage Oct 13 '12 at 05:51
-
1I think that's way better than monkey patching, and since Devise makes that option available, might as well go with that. – Benjamin Tan Wei Hao Oct 14 '12 at 17:32
0
Look in config/initializers/devise.rb
for
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming their account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming their account.
# config.allow_unconfirmed_access_for = 2.days
Set it to 1000.years. Then in your email_updates
method, call #confirmed?
to test if the user has confirmed their account. If not, send them to the page to re-send the confirmation link, as it will likely have expired by now.

Chloe
- 25,162
- 40
- 190
- 357