Created
October 30, 2009 20:41
-
-
Save dewski/222701 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class HomeController < ApplicationController | |
| def index | |
| feeds = Feed.find(:all, | |
| :conditions => ['created_at > ?', 5.days.ago], | |
| :order => 'created_at DESC', | |
| :limit => 15) | |
| # We now need to put each one into instance variable | |
| @items = feeds.collect do |item| | |
| # Translates to Comment.find(1), Connection.find(1), etc. | |
| # item_type returns a string that you can then initiate the model | |
| # and call any methods you normally would on it | |
| { :content => item.feedable_type.constantize.find(item.feedable_id), | |
| :item => item } | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment