Given the three models “message”, “profile” and “comment” i want to merge them into one list, ordered by their common attribute “created_at”. I want to accomplish something like the project overview in Basecamp – see 3) here: http://basecamphq.com/tour#overview
Share
Try something like this:
messages = Message.all
profiles = Profile.all
comments = Comment.all
list = [messages, profiles, comments].flatten
sorted_list = list.sort_by { |item| item.created_at.strftime(‘%m/%d/%y’) }