Reputation: 5
i want to select some rows from different tables and then i want to order them. how can i merge these results and order them according to their created_at values?
@books = Book.all
@notebooks = Notebook.all
@booksandnotebooks = ????
Upvotes: 0
Views: 338
Reputation: 32955
@booksandnotebooks = (@books + @notebooks).sort_by(&:created_at)
Isn't ruby lovely :)
Upvotes: 1