plataformatec/devise — Issue #1369: Devise:: Cannot create user through rake db:seed (failure confirmation_instructions)
Author: RitvvijParrikh
Created: 2011-10-08 15:16:40+00:00
State: open

User model has a function

def self.createadmin(
User.create(:email => "abc@gmail.com", :password => "123456e", :password_confirmation => "123456e", :terms_of_service => '1')
end

In rake db:seed, I have to call User.createadmin

However, this fails

ActionView::Template::Error: ActionView::Template::Error
from /Users/bever/Projects/tr/app/views/devise/mailer/confirmation_instructions.html.erb:3:in `_app_views_devise_mailer_confirmation_instructions_html_erb___1974818942364630283_2154906860'

Then I changed the code in createadmin

begin
User.create(:email => "abc@gmail.com", :password => "123456e", :password_confirmation => "123456e", :terms_of_service => '1')
rescue => e
User.create(:email => "abc@gmail.com", :password => "123456e", :password_confirmation => "123456e", :terms_of_service => '1')
end

It works! Any clue why this is happening?