Looking for a simple method utilizing active record to grab data from two models, combine the data, and then sort the combined output by created_at.
For example:
How about something like (untested):
class User < ActiveRecord::Base
scope :activities_by_date, :joins(:comments).joins(:likes).order("created_at desc")
end
Then you can do @user.activities_by_date
and let the db do all the work
I believe it should be as simple as:
combined_sorted = (User.comments + User.likes).sort{|a,b| a.created_at <=> b.created_at }