Oh boy.  So I looked at this, and I saw the other post you did with
the sample email activation lifecycle.  I'd like to help by organizing
all this information somewhere.  It's purely for selfish reasons, mind
you; I hate having to dig through posts to find what I need; plus, in
documenting it all, I'll be justified in asking a lot of stupid
questions about how things work.

Where should I put any documentation I write?  Is there a wiki, or
what?  I don't have git, I'm on a windows machine.

sd

On Sep 3, 3:37 am, Tom Locke <[EMAIL PROTECTED]> wrote:
> > OK, lifecycles is looking incredibly hot.  I read through the docs and
> > looked at the example code that comes with the generated user model.
> > I had a couple of questions:
>
> > - "transition :nobody", this, I'm guessing, is magic for 'guest
> > user'?
>
> Oh crikey. That's exactly the opposite of what it means! I think this  
> needs to be renamed.
>
> It's for "internal" transitions that are never automatically published  
> over the web.
>
> > Then what is :anybody under the 'create' definition?
>
> That means anyone can create the thing - no restrictions
>
> >  And what does the :if=>proc do?
>
> That's a pre-condition. The create/transition can only go ahead if the  
> proc returns true
>
> > - similarly, what does :with_key do?
>
> This means that only someone who knows the key is allowed to perform  
> the transition. The key would normally be provided by email a special  
> link that includes the key in the query string (see the user-mailer  
> for an example). It's used for things like forgotten password and  
> activate account, but could also be used to allow anyone who doesn't  
> have an account on the site to take part in a life-cycle.
>
> > - can you have a more complex user requirement for the transition?  My
> > specific example is similar to the Friendship example in the docs, but
> > it's more complex than that:
>
> > 1. An existing user can request membership in a group
> > 2. A user who has authority (e.g., they have an existing membership in
> > the group that has an is_admin? flag or something) can approve or deny
> > them
>
> > I'm not sure what the lifecycle definition would look like for a
> > transition like that.
>
> Here's a similar thing from an app of mine (not finished but will give  
> you some ideas)
>
> class GroupMembership < ActiveRecord::Base
>
>    hobo_model
>
>    fields do
>      administrator :boolean
>      timestamps
>    end
>
>    belongs_to :group
>    belongs_to :member,  :class_name => "Person"
>    belongs_to :sponsor, :class_name => "Person" # The admin that  
> invited/approved the membership (if any)
>
>    validates_presence_of :member, :group
>
>    attr_accessor :email_address, :type => :email_address
>
>    #named_scope :admin, :conditions => "administrator"
>
>    lifecycle do
>
>      precondition { group && member && member.not_in?(group.members) }
>
>      invariant { sponsor.nil? || sponsor.in?(group.administrators) }
>
>      state :requested, :invited
>
>      state :active do
>        # Mailer.notify_national_admins
>      end
>
>      create :sponsor, :invite, :params => [ :member, :group ], :become  
> => :invited do
>        # GroupMailer.deliver_invite(group, inviter, member)
>      end
>
>      create :sponsor, :invite_new_member, :params =>  
> [ :email_address ], :become => :invited do
>        # self.user = User.lifecycle.invite(:email => email, :inviter  
> => admin)
>      end
>
>      # TODO: become invited straight away for open groups
>      create :member,  :request, :params => [ :group ], :become  
> => :requested do
>        # GroupMailer.deliver_request(group, member)
>      end
>
>      transition :member,  :accept_invitation,  { :invited => :active }
>
>      transition :sponsor, :accept_request, { :requested => :active }
>
>      transition :sponsor, :reject_request, { :requested => :destroy }
>
>      transition :member,  :decline_invitation, { :invited => :destroy }
>
>      transition :member,  :cancel_membership, { [:requested, :active]  
> => :destroy }
>
>      transition :sponsor, :expell, { :active => :destroy }
>
>    end
>
> end
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to