禁用devise的:即时确认批量生成用户 [英] Disable devise's :confirmable on-the-fly to batch-generate users

查看:152
本文介绍了禁用devise的:即时确认批量生成用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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!

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

这篇关于禁用devise的:即时确认批量生成用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆