The callback confirmation happens after creation, so it happens on line 1 of your example before you set confirmed_at manually.
According to the comments, the most correct task would be to use the method provided for this purpose, #skip_confirmation! . Configuring confirmed_at manually will work, but it bypasses the provided API, which should be avoided if possible.
So something like:
user = User.new(user_attrs) user.skip_confirmation! user.save!
Original answer:
If you pass confirmed_at along with your create arguments, the mail should not be sent, since checking whether or not the account has already been "verified" is to see if this date is set.
User.create( :email => data['email'], :password => Devise.friendly_token[0,20], :confirmed_at => DateTime.now )
This or just use new instead of create to create your custom entry.
numbers1311407 Sep 19 '11 at 1:30 2011-09-19 01:30
source share