Items table id creator_id updated_at
Users table id
Itemlinks table user_id item_id
User model
Items table id creator_id updated_at
Users table id
Itemlinks table user_id item_id
User model
solution:
i.uniq! i = i.sort_by { |idea| idea.created_at } i.reverse!
Items table id creator_id updated_at
Users table id
Itemlinks table user_id item_id
User model ------------------ has_many :items_as_creator, :order => created_at has_many :items_through_itemlinks, :order => created_at
def items i = items_as_creator + item_through_itemlinks return i.uniq end
the question is, how do I ensure that the collection of items user.items is sorted by created_at? the orders on the has_manys don't work: consider
maybe...
User model
nope, each of the items sets by created_at doesn't work for the reasons explained above.