Have you turned the notification on? If so, the User
model is trying to send
the email notification. If you haven't configured your email server, the create operation
will fail.
I had to do the following to work around the problem.
1 Modify the User model
Add a virtual attribute called dont_notify
.
class User < ActiveRecord::Base
# add a attribute
attr_accessor dont_notify
end
2 Change the Observer code to detect the attribute.
class UserObserver < ActiveRecord::Observer
def after_create(user)
return if user.dont_notify? #notice this line
UserMailer.deliver_signup_notification(user)
end
def after_save(user)
return if user.dont_notify? #notice this line
UserMailer.deliver_activation(user) if user.recently_activated?
end
end
3 Set the dont_notify
flag during seeding
In you seed.rb
set the flag.
User.create(:login => 'admin',
:role => Role.find_by_name('super_admin'),
:email => '[email protected]',
:password => '123123',
:password_confirmation => '123123',
:dont_notify => true
)