# Restful\_authentication

**URL:** <https://www.ruby-forum.com/t/restful-authentication/144722>\
**Category:** Rails\
**Created:** [August 1, 2008, 2:56pm UTC](https://www.ruby-forum.com/t/restful-authentication/144722 "2008-08-01T14:56:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddtm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@ddtm](https://www.ruby-forum.com/u/ddtm)\
**Post date:** [August 1, 2008, 2:56pm UTC](https://www.ruby-forum.com/t/restful-authentication/144722/1 "2008-08-01T14:56:47Z")

</div>

I’ve decided to add user authentication to my application using  
restful\_authentication plugin. It has generated Account model with  
such fragment of code:

def create  
logout\_keeping\_session!  
@account = Account.new(params[:account])  
@account.register! if @account && @account.valid?  
success = @account && @account.valid?  
if success && @account.errors.empty?  
redirect\_back\_or\_default(’/’)  
flash[:notice] = “Thanks for signing up! We’re sending you an  
email with your activation code.”  
else  
flash[:error] = “We couldn’t set up that account, sorry.  
Please try again, or contact an admin (link is above).”  
render :action =\> ‘new’  
end  
end

Everything is clear to me except @account.register! method. I cannot  
find any documentation about it. Where should I seek?

---

<div class="post-metadata">

**Author:** ![ddtm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@ddtm](https://www.ruby-forum.com/u/ddtm)\
**Post date:** [August 1, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/restful-authentication/144722/2 "2008-08-01T16:10:44Z")

</div>

From the README  
– clip –

- –stateful: Builds in support for acts\_as\_state\_machine and  
generates  
activation code. (@–stateful@ implies @–include-activation@).  
Based on the  
idea at [[[http://www.vaporbase.com/postings/](http://www.vaporbase.com/postings/)  
stateful\_authentication]]. Passing  
@–skip-migration@ will skip the user migration, and @–skip-routes@  
will skip  
resource generation – both useful if you’ve already run this  
generator.  
– clip –

Using --stateful when running the restful\_authentication generator it  
builds in support for acts\_as\_state\_machine. If you are not using that  
plugin then generate restful\_authentication without the --stateful  
option.

@user.register! is a state transition. If you are unfamiliar with  
acts\_as\_state\_machine, either read up on that and use it, or don’t use  
the --stateful option.

P.S. @account in your case instead of @user.

---

<div class="post-metadata">

**Author:** ![ddtm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@ddtm](https://www.ruby-forum.com/u/ddtm)\
**Post date:** [August 1, 2008, 4:26pm UTC](https://www.ruby-forum.com/t/restful-authentication/144722/3 "2008-08-01T16:26:32Z")

</div>

Thanks. I’ll read about that.
