acting_user isn't defined in the proc space I believe.  the only thing
passed to is is the record.  you might be able to do r.acting_user.

a clearer way to do it though is make a named_scope that requires
debugmode be true, then you can just do :available_to =>
'User.scope_name_here'

from http://cookbook.hobocentral.net/manual/lifecycles#the__option if
passed a string, it will evaluate it and if the return is a
collection, it sees if the user is a member of the collection.

On May 6, 2:50 pm, Karsten Redmer <[email protected]> wrote:
> Thanks Brett.
>
> I got an error: undefined local variable or method `acting_user' for
> #<Class:0xb6ec9fa8>
>
> => in debugger I can't find "acting_user" !
>
> => in the proc "r" is the contact-record
>
> I have some more questions:
>
> in lifecycle/available_to-manual I find this:
>
> - A proc – if the proc takes one argument it is called with the
> record, if it takes none it is instance_eval‘d on the record
> Q: what ist the meaning of this or how can I use the difference?
>
> The value returned is then used to determine if the acting_user has
> access or not. The value is expected to be:
>     * A class – access is granted if the acting_user is a kind_of?
> that class.  THAT IS WORKING => "User"
>     * A collection – if the value responds to :include?, access is
> granted if include?(acting_user) is true. e.g.
>     * A record – if the value is neither a class or a collection,
> access is granted if the value is the acting_user
>
> Q: maybe the problem I have is because the contact-model has a
> lifecycle and I can't access the acting_user???
>
> - If I just put "acting_user if acting_user.signed_up?" to lifecycle-
> transition it it NOT working!
> - if I take "User" it works.
> - @acting_user is available !
>
> Thanks,
> Karsten
>
> On 6 Mai, 19:05, Brett Nelson <[email protected]> wrote:
>
>
>
> > If it's going to be code it needs to be a proc.
>
> > something like
>
> > available_to_debug_user = Proc.new do |r|
> >   if (acting_user.is_a?(User) and acting_user.debugmode)
> >     acting_user
> >   else
> >     nil
> >   end
> > end
>
> > available_to => available_to_debug_user
>
> > If you look at the hobo cookbook manual it has a nice section on
> > available_to in lifecycles that explains it. I have not tested it this
> > way though...
>
> > Brett
>
> > On May 6, 10:00 am, Karsten Redmer <[email protected]> wrote:
>
> > > Hi,
>
> > > I want to have a condition for my transition if debugmode is set for
> > > the (acting-user in order to display the transition-button or not -
> > > and even to restrict access to it)
>
> > > When I  take available_to "User" I can see the transition button. When
> > > I try  "User if User.debugmode" I don't see it. Acting_user don't
> > > work, too.
>
> > > How can I solve this ?
>
> > > ( I tried several things, but nothing worked well)
>
> > > Thanks,
> > > Karsten
>
> > > my Contact-Transition:
>
> > > transition :chooseuplineback, { :ready
> > > => :missingUpline }, :available_to => "User if User.debugmode"
>
> > > my user-model:
>
> > > class User < ActiveRecord::Base
>
> > >   hobo_user_model # Don't put anything above this
>
> > >   fields do
> > >     email_address :email_address, :unique, :name => true, :login =>
> > > true
> > >     administrator :boolean, :default => false
> > >     firstname  :string
> > >     lastname    :string
> > >     debugmode :boolean, :default => false
> > >     timestamps
> > >   end
> > >   has_many :successes
> > >   has_many :contacts, :class_name => "Contact", :through => :successes
>
> > > ++++++++++++
>
> > > my contact-model:
>
> > > class Contact < ActiveRecord::Base
>
> > >   hobo_model # Don't put anything above this
>
> > >   fields do
> > >     companyname :string
> > >     lastname  :string
> > >     firstname :string
> > >     email :email_address, :required
> > >    ...
> > >   end
>
> > >   has_many :successes
> > >   has_many :users, :class_name => "User", :through => :successes
>
> > > --
> > > 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 
> > > athttp://groups.google.com/group/hobousers?hl=en.
>
> > --
> > 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 
> > athttp://groups.google.com/group/hobousers?hl=en.
>
> --
> 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 
> athttp://groups.google.com/group/hobousers?hl=en.

-- 
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