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?
–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/
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.