Вопрос

Windows 8.1 Ruby 2.0.0 Rails 4.1 Devise 3.xx

In my registrations_controller, I have the following:

@user.skip_confirmation!

prior to saving. This is working only partially, as confirmation email is not being sent out, but the confirmed_at field is being filled, and I can login using the credentials I used to register.

How do I skip confirmation altogether? If there are recommendations on how to confirm later (by an admin), that would be great.

Это было полезно?

Решение

As you don't want them to be able to login until they've later been confirmed by an admin, you can use skip_confirmation_notification! instead of skip_confirmation!. This will create the confirmation token and the user will need to be confirmed, but it won't send the email notification to enable them to confirm themselves. They won't be able to log in until they're confirmed. You can then call user.confirm! for an admin to confirm the user later. This should do the job, but the source code/comments might be worth a browse:

https://github.com/plataformatec/devise/blob/master/lib/devise/models/confirmable.rb

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top