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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
DJ Cole
2010-Apr-10 20:38 UTC
Re: restful authentication help : updates never reach databa
DJ Cole wrote:> my setup:save(false)> > acts_as_state_machine latches onto after_create, and THEN plops in the > authentication_code) ... alas, save(false, or any subsequent calls toThat should read "activation_code ...." -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.