bcardarella
2008-Sep-08 18:54 UTC
Restful Authentication and State Machine state transfer question
I''m adding some code to a project using restful_authentication and acts_as_statemachine In the create method for a user there is the following code generated by the restful_authentication template @user.regster! if user.valid? And this will save and the user record if it is valid. I understand that the statemachine will then change the state from passive to pending. It will guard against this by validating that the crypted_password and password getters are not blank. This I understand. I am not seeing anything in the code that actually does an ActiveRecord::Base.save on it. restful_authentication seems to be pretty much just generated templates and I cannot find any code that saves the record and there doesn''t seem to be anything in acts_as_statemachine that recognizes this particular state change and saves the record. Perhaps I am missing something or maybe there is something else going on that saves the record. I don''t see any type of observer running that will save the record upon a state change. I understand the purpose of state machines but for whatever reason I just cannot see how this plugin is saving the record. Any help would be appreciated. - Brian Cardarella --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
bcardarella
2008-Sep-08 19:06 UTC
Re: Restful Authentication and State Machine state transfer question
Nevermind.. In the acts_as_statemachine plugin the dynamically generated event methods make a call to ''fire'' which in turn makes a call to ''perform'' which does an ''update_attribute'' against the record which does a save on the record. I hope this helps somebody else. - Brian Cardarella On Sep 8, 2:54 pm, bcardarella <bcardare...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m adding some code to a project using restful_authentication and > acts_as_statemachine > > In the create method for a user there is the following code generated > by the restful_authentication template > > @user.regster! if user.valid? > > And this will save and the user record if it is valid. I understand > that the statemachine will then change the state from passive to > pending. It will guard against this by validating that the > crypted_password and password getters are not blank. This I > understand. I am not seeing anything in the code that actually does an > ActiveRecord::Base.save on it. restful_authentication seems to be > pretty much just generated templates and I cannot find any code that > saves the record and there doesn''t seem to be anything in > acts_as_statemachine that recognizes this particular state change and > saves the record. Perhaps I am missing something or maybe there is > something else going on that saves the record. I don''t see any type of > observer running that will save the record upon a state change. I > understand the purpose of state machines but for whatever reason I > just cannot see how this plugin is saving the record. Any help would > be appreciated. > > - Brian Cardarella--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Walker
2008-Sep-08 21:29 UTC
Re: Restful Authentication and State Machine state transfer
> ActiveRecord::Base.save on it. restful_authentication seems to be > pretty much just generated templates and I cannot find any code that > saves the record and there doesn''t seem to be anything inActually restful_authentication is not simply a code generator when using acts_as_state_machine or aasm. It does actually call into code within the plugin to perform the state changes and update the database. At least I think it''s the case with acts_as_state_machine. The project I am currently working on is using aasm rather than the older act_as_state_machine. In my case I have this line at the top of my User model along with a few other includes: include Authorization::AasmRoles So this is where all the state machine magic is happening. Brian Cardarella wrote:> I''m adding some code to a project using restful_authentication and > acts_as_statemachine >> In the create method for a user there is the following code generated > by the restful_authentication template > > @user.regster! if user.valid? > > And this will save and the user record if it is valid. I understand > that the statemachine will then change the state from passive to > pending. It will guard against this by validating that the > crypted_password and password getters are not blank. This I > understand. I am not seeing anything in the code that actually does an > ActiveRecord::Base.save on it. restful_authentication seems to be > pretty much just generated templates and I cannot find any code that > saves the record and there doesn''t seem to be anything in > acts_as_statemachine that recognizes this particular state change and > saves the record. Perhaps I am missing something or maybe there is > something else going on that saves the record. I don''t see any type of > observer running that will save the record upon a state change. I > understand the purpose of state machines but for whatever reason I > just cannot see how this plugin is saving the record. Any help would > be appreciated. > > - Brian Cardarella-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---