[Rails] Re: Distinct selection

2008-11-25 Thread Yan Oleg
assignable? is just a filter to select roles that have attribute assignable set to true. Regarding roles... I want to select not all roles, but roles that are members of project. And also I cannot change database structure. So I have the following entities relations: Roles - Members -

[Rails] Re: Distinct selection

2008-11-25 Thread Yan Oleg
Thanks to Harold. I used uniq method and it worksfine!! :) Thank you! -- 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

[Rails] Re: Distinct selection

2008-11-21 Thread Yan Oleg
Yan Oleg wrote: I have the following code: members.select {|m| m.role.assignable?}.collect {|m| m.role}.sort There are two tables: roles and members. One role record may have many foreign member records. But in this case I get many same roles, I want to apply distinct operation to

[Rails] Re: Distinct selection

2008-11-21 Thread James Mitchell
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 [EMAIL PROTECTED] wrote: Yan Oleg wrote: I have the following code:

[Rails] Re: Distinct selection

2008-11-21 Thread James Mitchell
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