views:

289

answers:

2

I recently installed the technoweenie / restful-authentication plugin (which works as promised), but while going through the *users_controller#created*, I found a reference to a method call on the user model

 @user.register!

Does anyone know where the method is defined? I've pretty much search all of the generated code, and still don't see a register method.

Thanks.

H

A: 

Run the restful auth generators

rabble
+3  A: 

It's defined in restful-authentication/lib/authorization/stateful_roles.rb

    event :register do
      transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
    end

The actual method register! is created dynamically from this event by the acts_as_state_machine plugin that should be in your project as well. This method was inserted into your controller because when you generated your controller you specified either --stateful or '--aasm'.

There is a very good write up on acts_as_state_machine here if you would like to learn more.

vrish88
no problem, I actually was trying to figure out where this was coming from last week :)
vrish88
Thank you so much for this, was tearing my hair out over it
localshred