Ok, maybe we misunderstood each other.

If you want a list of roles, why would you go through the members
table to get it?  You can just do Roles.find(:all).map(&:name)

I'm not sure what you doing with "assignable?".  It seems to be
important to you, but you have not explained what it is supposed to
return.

What does it do?  Does it return:
  a) members who do not have a role and are therefore able to be
assigned a role ?
  b) some awkward pass-through delegation to roles that aren't assigned yet ?


--
James Mitchell



On Fri, Nov 21, 2008 at 9:51 AM, Yan Oleg
<[EMAIL PROTECTED]> wrote:
>
> James Mitchell wrote:
>> What exactly are you trying to do?
>>
>> From reading what you wrote, it sounds like you want a list of roles
>> that have not already been assigned.  Is that right?
>>
>> --
>> James Mitchell
>>
>>
>>
>> On Fri, Nov 21, 2008 at 8:59 AM, Yan Oleg
>
> NO, it isn't right.
>
> If I use this code:
>
> members.select {|m| m.role.assignable?}.collect {|m| m.role}.sort
>
> ...I get several roles with the same ID and NAME, but I want to get
> unique ones, like using DISTINCT operation in SQL statements (SELECT
> DISTINCT name FROM roles.....)
>
> But unfortunately I can get the list from table "members", where records
> may have several same role names:
>
> Manager
> Tester
> Manager
> Manager
> Manager
> Tester
> Developer
> Developer
> Tester
> Developer
> Tester
> Developer
> Developer
> Developer
>
> But I have to get this list:
>
> Manager
> Tester
> Developer
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to