# Inconsitent fault with my UserEngine/LoginEngine

**URL:** <https://www.ruby-forum.com/t/inconsitent-fault-with-my-userengine-loginengine/101785>\
**Category:** Engines\
**Created:** [August 7, 2006, 11:11pm UTC](https://www.ruby-forum.com/t/inconsitent-fault-with-my-userengine-loginengine/101785 "2006-08-07T23:11:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickerbh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bb73d2/32.png) [@rickerbh](https://www.ruby-forum.com/u/rickerbh)\
**Post date:** [August 7, 2006, 11:11pm UTC](https://www.ruby-forum.com/t/inconsitent-fault-with-my-userengine-loginengine/101785/1 "2006-08-07T23:11:53Z")

</div>

Hi,

I’ve got a bizarre, seemingly random error with my instance of  
UserEngine or LoginEngine. It occurs _sometimes_ when new users attempt  
to signup to my application. The error message in the log files is

Unable to send confirmation E-Mail:  
undefined method `+’ for nil:NilClass

To try and figure out what’s going on here I’ve copied and pasted some  
methods from AuthenticatedUser within LoginEngine, and introduced my own  
trace statements. It looks like it’s getting through to  
new\_security\_token within AuthenticatedUser, but I believe it’s failing  
on this line

write\_attribute(‘security\_token’,  
AuthenticatedUser.hashed(self.salted\_password + Time.now.to\_i.to\_s +  
rand.to\_s))

I’m guessing that the + has got something to do with no salted\_password  
being defined for the user…?

Has anyone encountered this before, or can think of a series of actions  
that would cause a new user (during signup) to have no salted\_password  
created for them?

This is really bugging me, as the only way I’ve found to fix it is to  
restart my app - and that’s hardly a fix.

And help or tips would be appreciated.

Thanks,

Hamish Rickerby  
hamish [at] [glimmerdesign.com](http://glimmerdesign.com)  
[http://gotthegist.co.nz](http://gotthegist.co.nz)

---

<div class="post-metadata">

**Author:** ![rickerbh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bb73d2/32.png) [@rickerbh](https://www.ruby-forum.com/u/rickerbh)\
**Post date:** [August 7, 2006, 11:43pm UTC](https://www.ruby-forum.com/t/inconsitent-fault-with-my-userengine-loginengine/101785/2 "2006-08-07T23:43:31Z")

</div>

I’ve just been looking at the code on this a little more, and I’m  
wondering if the callback to crypt\_password is executing correctly - as  
I see it that’s where the creation of the salted\_password is supposed to  
happen, just after the validations and just before the save to db…  
Does that give anyone any hints on what could be wrong with my app?  
Anyone found that for some odd reason/configuration it fails to trigger  
all the time?

Thanks,

H.

---

<div class="post-metadata">

**Author:** ![rickerbh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bb73d2/32.png) [@rickerbh](https://www.ruby-forum.com/u/rickerbh)\
**Post date:** [August 14, 2006, 11:23pm UTC](https://www.ruby-forum.com/t/inconsitent-fault-with-my-userengine-loginengine/101785/3 "2006-08-14T23:23:09Z")

</div>

I’ve fixed it. It was the same problem that other users have reported  
with transactions not being saved correctly. Removal of the  
User.transaction cleared that right up.

So, for anyone else in the future who is wondering why their email  
messages aren’t being sent from the login\_engine, and they just get a

Unable to send confirmation E-Mail:  
undefined method `+’ for nil:NilClass

message in the log files - REMOVE the transaction around the majority of  
the signup method in your overwritten user\_controller.rb.

* * *

Hamish Rickerby  
hamish [at] [glimmerdesign.com](http://glimmerdesign.com)  
[http://gotthegist.co.nz](http://gotthegist.co.nz)
