A scope on the model - from the lifecycle docs I assume - will do a 
database query (which might or might not get optimized away). A Proc should 
allow you to directly test the fields of the User object that is already in 
memory, with no further database access.

As a sidenote, Hobo automatically gives you scopes on all boolean fields 
<http://hobocentral.net/manual/scopes#boolean-scopes>, you don't need to 
explicitly define them.

2015. július 23., csütörtök 16:00:02 UTC+2 időpontban Nathan Peters a 
következőt írta:
>
> I have a scope in User to make it easier to work with users who have a 
> tasker boolean set:
>
> scope :tasker, :conditions => {:tasker => true}
>
> ..and am using this in lifecycle transitions
>
>      transition :delete,
>                {:submitted => :destroy},
>                :available_to => :owner
>
>     transition :delete,
>                {[:submitted, :accepted, :funding] => :destroy},
>                :available_to => "User.tasker"
>
> This works great unless someone is an owner *and* a tasker, then I get two 
> delete buttons.
>
> I figure I need to have one delete transition that combines :owner and 
> User.tasker with a Proc or define another scope in User. Is there a reason 
> to prefer one method over the other?
>
> Thanks
> Nathan
>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to