# Restful\_authentication with rails 2.2

**URL:** <https://www.ruby-forum.com/t/restful-authentication-with-rails-2-2/160286>\
**Category:** Rails\
**Created:** [February 13, 2009, 6:37pm UTC](https://www.ruby-forum.com/t/restful-authentication-with-rails-2-2/160286 "2009-02-13T18:37:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac8455/32.png) [@Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/u/Rodrigo_MuiSSSSo)\
**Post date:** [February 13, 2009, 6:37pm UTC](https://www.ruby-forum.com/t/restful-authentication-with-rails-2-2/160286/1 "2009-02-13T18:37:04Z")

</div>

Guys, I am using restful\_authentication with rails 2.2 an realized that  
when  
a user tries to sign up the activation code that is set to his email is  
different from the one in the database.  
Do you know if this is an issue of rails 2.2?  
It used to work fine withe rails 2.1

Thanks  
Rodrigo

---

<div class="post-metadata">

**Author:** ![Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac8455/32.png) [@Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/u/Rodrigo_MuiSSSSo)\
**Post date:** [February 14, 2009, 8:11pm UTC](https://www.ruby-forum.com/t/restful-authentication-with-rails-2-2/160286/2 "2009-02-14T20:11:38Z")

</div>

I have recently setup restful\_auth… on 2.2.2 and all the unit tests  
passed  
except for a little correction in the users.yml (fixture)

I have been able to successfully create and activate users.

I did setup with acts\_as\_state\_machine (AASM) too.

Some things I would check-

Did the migration from 2.1 to 2.2 succeed?

Are the unit tests successful?

Hope this helps.

-Master Chief

(RoR noob)

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Rodrigo MuiÃ±o  
Sent: Friday, February 13, 2009 9:36 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Rails] restful\_authentication with rails 2.2

Guys, I am using restful\_authentication with rails 2.2 an realized that  
when  
a user tries to sign up the activation code that is set to his email is  
different from the one in the database.  
Do you know if this is an issue of rails 2.2?  
It used to work fine withe rails 2.1

Thanks  
Rodrigo

---

<div class="post-metadata">

**Author:** ![Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac8455/32.png) [@Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/u/Rodrigo_MuiSSSSo)\
**Post date:** [February 24, 2009, 6:00pm UTC](https://www.ruby-forum.com/t/restful-authentication-with-rails-2-2/160286/3 "2009-02-24T18:00:56Z")

</div>

Same problem here. I did setup with AASM.  
Walking through the source it looks like the function in the model to  
generate the activation code is being called twice. Once before save,  
and then mysteriously again before the mailer. I’m not sure why this  
second call is happening, but that’s why the email (and the output in  
the logfile) is wrong.  
Let me know if you came up with a fix.  
A.

---

<div class="post-metadata">

**Author:** ![Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac8455/32.png) [@Rodrigo\_MuiSSSSo](https://www.ruby-forum.com/u/Rodrigo_MuiSSSSo)\
**Post date:** [February 25, 2009, 12:39am UTC](https://www.ruby-forum.com/t/restful-authentication-with-rails-2-2/160286/4 "2009-02-25T00:39:15Z")

</div>

This issue is noted right on the plugins github page:

> **[GitHub - technoweenie/restful-authentication: inactive project](https://github.com/technoweenie/restful-authentication/tree/master)**
>
> master

"Pay attention, may be this is not an issue for everybody, but if you  
should have problems, that the sent activation\_code does match with  
that in the database stored, reload your user object before sending  
its data through email something like:

```
class UserObserver < ActiveRecord::Observer
  def after_create(user)
    user.reload
    UserMailer.deliver_signup_notification(user)
  end
  def after_save(user)
    user.reload
    UserMailer.deliver_activation(user) if

```

user.recently\_activated?  
end  
end  
"
