my setup: OS X 10.6.3 rails (2.3.5) sqlite
the problem: moving this old code to a new project (I didn't want to hunt down yet-another-authentication module as I can't tell what is abandoned or not, I figured copy paste would be the quickest - no such luck), basic user authentication is broken. I found several and fixed several pieces of broken code, but now I am stuck at: ActiveRecord refuses to save changes to the User model, in particular: when the acs_as_state_machine has changed the value.
e.g. this state machine will call a Model method: def make_activation_code self.activation_code= ... end
as a result of a state change (from <non existent | passive state> -> pending
A state change occurs on object create, but, ironically, thanks to acts_as_state_machine's plugin setup, AFTER the object has already been stored into the database.
The original code had a u = User.new(...) u.register! ... etc.
all of which would store nothing at all the the database (this was raw original generator code unmodified, and used to work)
I then tried: u = User.create() (force the object creation) ...
and u = User.new(...) u.register! u.save! u.save(false)
the latter lines with printouts confirm the u finally has the right activation code (in this case, after save!, because acts_as_state_machine latches onto after_create, and THEN plops in the authentication_code) ... alas, save(false, or any subsequent calls to save, and the setting of the authentication_code inside the model fail to update the database, and these changes to the object are lost forever...
What am I missing?