Sorting 2 arrays that have been added together
- by tyler
In my app, users can create galleries that their work may or may not be in. Users have and belong to many Galleries, and each gallery has a 'creator' that is designated by the gallery's user_id field.
So to get the 5 latest galleries a user is in, I can do something like:
included_in = @user.galleries.order('created_at DESC').uniq.first(5)
#…