开发者

Disable devise's :confirmable on-the-fly to batch-generate users

Devise is a Ruby library that provides me with this User class:

class User < ActiveRecord::Base
  has_many :user_tokens
  devise :trackable, :confirmable

When :confirmable is written, a confirmation email is sent upon registration.

Last week I had to batch-create 300 users, so I commented out :confirmable for a few minutes before reverting.

Now I am creating a UI for user batch-creation, so I need to add/remove :confirmable on-the-fl开发者_JS百科y. (I could also modify Devise's source code directly but I would rather not temper with it)

QUESTION: How to add/remove :confirmable on-the-fly?


Solution by Wayne Conrad:

user = User.new
user.skip_confirmation!

http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable#skip_confirmation!-instance_method

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜