So for example ...
Lets say I have a Posts model and a News model, that are essentially the same thing (structure wise) columns are * title * content * createdat * updatedatThe client has requested showing both news and Posts on the same page interleaved and sorted by created开发者_Go百科_at date ...
Does anyone know how I would go about doing something like this?(Post.all + News.all).sort_by(&:created_at)
Just a warning, cwninja's answer will be really slow with large datasets because it requires pulling ALL of the members out of the database and then running a sort on them.
I would rarely suggest raw SQL, but in this case I can't think of a better way.
精彩评论