禁用devise的:即时确认批量生成用户 [英] Disable devise's :confirmable on-the-fly to batch-generate users
问题描述
Devise 是一个Ruby库,为我提供了这个用户
class:
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.
上周我不得不批量创建300个用户,所以我评论了:可确认
几分钟后还原。
Last week I had to batch-create 300 users, so I commented out :confirmable
for a few minutes before reverting.
现在我正在创建一个UI对于用户批量创建,所以我需要在运行时添加/删除:confirmable
。 (我也可以直接修改Devise的源代码,但是我宁愿不用这么做)
Now I am creating a UI for user batch-creation, so I need to add/remove :confirmable
on-the-fly. (I could also modify Devise's source code directly but I would rather not temper with it)
QUESTION:如何添加/删除:confirmable
on-the-fly?
QUESTION: How to add/remove :confirmable
on-the-fly?
推荐答案
Wayne Conrad的解决方案: p>
Solution by Wayne Conrad:
user = User.new
user.skip_confirmation!
这篇关于禁用devise的:即时确认批量生成用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!