Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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-fly. (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?

like image 801
Nicolas Raoul Avatar asked Oct 04 '11 05:10

Nicolas Raoul


1 Answers

Solution by Wayne Conrad:

user = User.new
user.skip_confirmation!

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

like image 87
Nicolas Raoul Avatar answered Oct 15 '22 11:10

Nicolas Raoul