Prepare for more annoying lifecycle questions. :) Some of them I just
want to clarify, so I'm not documenting the wrong thing.
On Sep 4, 7:33 am, Tom Locke <[EMAIL PROTECTED]> wrote:
> initial_state :inactive
>
> state :active
>
> create :anybody, :signup,
> :params =>
> [:username, :email_address, :password, :password_confirmation],
> :become => :inactive, :if => proc {|_, u| u.guest?} do
> UserMailer.deliver_activation(self,lifecycle.generate_key)
> end
1. Confirm: initial_state also does everything that state does
2. Does initial_state set a database default, or does it hook in to a
before_create or after_create or something?
3. If you have an initial_state declared, why does the 'create'
declaration specify to :become=>:inactive? Is initial_state redundant
in this case?
3.1 'create' is sort of life a transition definition, but at the class
level?
4. Confirm: create :anybody is a magic word that means its completely
and totally open: guest included.
5. in the create :if=> block, what are the two parameters? |_,u|
> transition :with_key, :activate, { :inactive => :active }
6. :with_key is also a magic keyword? You explained what it was for,
I don't know if it's a magic word or if its referring to something
somewhere else in the framework.
> transition :nobody, :request_password_reset, { :inactive
> => :inactive } do
> UserMailer.deliver_activation(self,lifecycle.generate_key)
> end
>
> transition :nobody, :request_password_reset, { :active
> => :active } do
> UserMailer.deliver_forgot_password(self,lifecycle.generate_key)
> end
7. I get what :nobody is supposed to do, what I don't get is why you'd
use it in this case. A password reset is going to be initiated by a
guest user, isn't it? Someone who is at the site, but can't log in?
It seems to me like the way this is defined:
@this.lifecycle.request_password_reset(current_user)
its going to fail.
> transition :with_key, :reset_password, { :active => :active },
> :update => [ :password, :password_confirmation ]
8. how is this used in a controller?
Idioms:
9. Have you considered 'transition <what>, <who>' instead of '<who>
<what>'? The former seems more readable; the <what> has to change
every line. (you probably shouldnt declare the same transition twice,
i'm guessing) Whereas, the <who> could be the same each time.
10. Similarly, 'creation' (n) might be easier to grok than
'create' (v). Create has a well-defined place in Rails lingo. You're
not creating anything here, you're defining how it can be created: its
creation. Also creation/transition match up. Model::Lifecycle
creates, whereas record.lifecycle... transits. Or something.
Thanks in advance,
sd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---