Matt and Kevin, thanks a lot for help.

I'm just newbie in Hobo and, frankly speaking, in RoR as well : )

Therefore, I did not think about efficiency that much - just about how
to do what I need.

I appreciate your advice.

Denis.

On 8 окт, 01:36, Matt Jones <[email protected]> wrote:
> On Oct 7, 2010, at 5:09 PM, kevinpfromnm wrote:
>
>
>
>
>
> > doh, I'm sorry.  sleep deprived lately.
>
> > watch your solution there as it will grab every other user so if your
> > user base is large, that will be a real memory hog/slowdown.
>
> > could try (I'm not sure if acting_user is defined at this point or
> > not), "User unless owner_is? acting_user" # using owner_is? avoids
> > having to load the association if not already loaded.
>
> > That should work if acting_user is available when it evaluates.
> > should return false if owner_is? acting_user and User if not.  That's
> > a little unintuitive that passing true to available_to doesn't make it
> > available.
>
> > On Oct 7, 1:48 pm, Denis <[email protected]> wrote:
> >> Hi,
>
> >> Your suggestions have guided me to right solution : )
> >> Correct way to do that I need is following:
> >>             :available_to => "User.is_not(#{:owner})"
>
> Couple notes on this - as Kevin pointed out, this loads all the other users. 
> Also, there's a lot of excess punctuation here, as the double-quoted string 
> is expanded during class definition - it's equivalent to 'User.is_not(owner)'.
>
> It's actually a pretty tricky problem, since you want to generate a list of 
> "everybody but that record" without actually loading everybody. But, some 
> metaprogrammery can save the day:
>
> In the class with the lifecycle, add:
>
>   def not_owners
>     r = Array.new
>     this = self
>     r.meta_def :include? do |x|
>       x.id != this.user_id
>     end
>     r
>   end
>
> Then set :available_to => :not_owners, which will call the method to get an 
> array of users the transition should be available to, which has been 
> spring-loaded to return the correct answers... You may also want to add a 
> check to see if x is a guest as well; the current method will return true for 
> them by default.
>
> --Matt Jones

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