Merge two ActiveRecord arrays and order by created_at

Viewed 31450
books = Book.find(:all)
articles = Articles.find(:all)

By reading from http://guides.rubyonrails.org/layouts_and_rendering.html I knew that I could do something like:

<%= render :partial => [customer1, employee1, customer2, employee2] %>

and it would use _customer and _employee partials as appropriate.

So I want to do something like that:

materials = books + articles
materials.sort_by_created_at

and in the view:

<%= render :partial => materials %>

How to do the merging and sorting of two ActiveRecord arrays???Thanks for help!

2 Answers
Related