Module: Devise::Models::Confirmable::ClassMethods
- Defined in:
- lib/devise/models/confirmable.rb
Instance Method Summary collapse
-
#confirm!(attributes = {}) ⇒ Object
Find a user by it’s confirmation token and try to confirm it.
-
#send_confirmation_instructions(attributes = {}) ⇒ Object
Attempt to find a user by it’s email.
Instance Method Details
#confirm!(attributes = {}) ⇒ Object
Find a user by it’s confirmation token and try to confirm it. If no user is found, returns a new user with an error. If the user is already confirmed, create an error for the user Options must have the confirmation_token
142 143 144 145 146 147 148 149 150 |
# File 'lib/devise/models/confirmable.rb', line 142 def confirm!(attributes={}) confirmable = find_or_initialize_by_confirmation_token(attributes[:confirmation_token]) if confirmable.new_record? confirmable.errors.add(:confirmation_token, :invalid) else confirmable.confirm! end confirmable end |
#send_confirmation_instructions(attributes = {}) ⇒ Object
Attempt to find a user by it’s email. If a record is found, send new confirmation instructions to it. If not user is found, returns a new user with an email not found error. Options must contain the user email
132 133 134 135 136 |
# File 'lib/devise/models/confirmable.rb', line 132 def send_confirmation_instructions(attributes={}) confirmable = find_or_initialize_with_error_by_email(attributes[:email]) confirmable.reset_confirmation! unless confirmable.new_record? confirmable end |