Skip to content

Commit

Permalink
Option to validate upon #confirm!
Browse files Browse the repository at this point in the history
Allow to ensure valid upon confirming.
We might want to consider confirmation status in validations. For example, maybe we want to require certain fields upon confirmation, but not at registration.
  • Loading branch information
timscott committed Nov 19, 2014
1 parent c54e986 commit 4ba84ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/devise/models/confirmable.rb
Expand Up @@ -56,7 +56,7 @@ def self.required_fields(klass)
# Confirm a user by setting it's confirmed_at to actual time. If the user
# is already confirmed, add an error to email field. If the user is invalid
# add errors
def confirm!
def confirm!(ensure_valid=false)
pending_any_confirmation do
if confirmation_period_expired?
self.errors.add(:email, :confirmation_period_expired,
Expand All @@ -75,7 +75,7 @@ def confirm!
# We need to validate in such cases to enforce e-mail uniqueness
save(validate: true)
else
save(validate: false)
save(validate: ensure_valid)
end

after_confirmation if saved
Expand Down

0 comments on commit 4ba84ee

Please sign in to comment.