# Working around Restful Authentication

**URL:** <https://www.ruby-forum.com/t/working-around-restful-authentication/141693>\
**Category:** Rails\
**Created:** [June 29, 2008, 3:54pm UTC](https://www.ruby-forum.com/t/working-around-restful-authentication/141693 "2008-06-29T15:54:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nik\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@Nik\_B](https://www.ruby-forum.com/u/Nik_B)\
**Post date:** [June 29, 2008, 3:54pm UTC](https://www.ruby-forum.com/t/working-around-restful-authentication/141693/1 "2008-06-29T15:54:42Z")

</div>

I’m using Restful Authentication, and the code to create a user is  
pretty straight forward - there is a before\_save action and a  
before\_create action:

before\_save :encrypt\_password  
before\_create :make\_activation\_code

But for some reason when I try to create a user programmatically in  
the controller like this:

User.new(:email =\> ‘removed\_email\_address@domain.invalid’, :password =\>  
‘123456’, :password\_confirmation =\> ‘123456’)

Nothing happens. I get a user that I can’t save:

> u = User.new(:email =\> ‘removed\_email\_address@domain.invalid’, :password =\> ‘123456’, :password\_confirmation =\> ‘123456’)  
> =\> #\<User id: nil, login: nil, email: “removed\_email\_address@domain.invalid”,  
> crypted\_password: nil, salt: nil, created\_at: nil, updated\_at: nil,  
> remember\_token: nil, remember\_token\_expires\_at: nil, activation\_code:  
> nil, activated\_at: nil, is\_seller: false\>
> 
> > u.save  
> > =\> false

Any clues as to how I could create a user without actually being sent  
to the user controller’s create action? The before\_save and  
before\_create actions are private.

Thanks,  
Nik

---

<div class="post-metadata">

**Author:** ![Nik\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@Nik\_B](https://www.ruby-forum.com/u/Nik_B)\
**Post date:** [June 30, 2008, 7:35am UTC](https://www.ruby-forum.com/t/working-around-restful-authentication/141693/2 "2008-06-30T07:35:06Z")

</div>

Did you check the validation errors after trying to save the user? Are  
you sure you are providing all the required information required by  
the validation on the user model?
