KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This is a follow up to Creating "feeds" from multiple, different Rails models . In this question, tadman suggests this method of creating a user feed of recent items from three models (Ticket, Post, Report): @items = [ Ticket, Post, Report ].inject([ ]) do |a, with_class| a + with_class.find(:all, :limit => 10, :order => 'created_at DESC') end.sort_by(&:created_at).reverse[0, 10] He suggests this as a method that will work, but that won't necessarily be the most efficient. He suggests as well than an alternative method would be to "create an index table that's got a polymorphic association with the various records." I'm really interested in learning more about this alternative solution, it seems both more efficient and more elegant. Can anyone tell me how one would do this? Let's use the same background info from the last question as a base.
Tags (comma-separated)
Save Edits
Cancel