On 3 June 2011 19:19, Tim Shaffer <timshaf...@me.com> wrote:
> I think the problem with doing that is that the arrays contain instances of
> models.

I .uniq arrays of instances of models all the time - it's a very handy tool.

>> u1 = User.first
=> #<User id: 1, name: "mgp", person_id: 6, created_at: "2010-01-23
18:49:58", updated_at: "2010-05-09 20:02:47", role_name:
"super_admin">
>> u1.object_id
=> -614919958
>> u2 = User.first
=> #<User id: 1, name: "mgp", person_id: 6, created_at: "2010-01-23
18:49:58", updated_at: "2010-05-09 20:02:47", role_name:
"super_admin">
>> u2.object_id
=> -614928398
>> [u1, u2].uniq
=> [#<User id: 1, name: "mgp", person_id: 6, created_at: "2010-01-23
18:49:58", updated_at: "2010-05-09 20:02:47", role_name:
"super_admin">]

> Sounds like skt wants to consider an instance unique based on only two
> attributes of each instance.

If so, then collecting up just those values and .uniq on them would
still be readable, as a one liner or broken into a couple, or doing a
.group_by and checking the size of the hash....

(some sample data from the OP would help clarify things if it's still
an issue after the suggestions)

M

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to