Created
April 20, 2011 16:52
-
-
Save mokolabs/931887 to your computer and use it in GitHub Desktop.
This file contains 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
# CONTROLLER | |
# Recent comments on theaters | |
comments = Comment.find(:all, :conditions => "entity_type = 'Theater'", :order => "id DESC", :select => "entity_id", :limit => 100) | |
comments = comments.map{ |i| i.entity_id }.uniq | |
theaters = Theater.find(:all, :conditions => "id IN (#{comments.join(',')})") | |
@theaters_with_comments = theaters.sort_by{|e| comments.index(e.id)} | |
# VIEW | |
%h2 Recent comments | |
%ul | |
- @theaters_with_comments[0..9].each do |theater| | |
%li= link_to theater.name, theater_path(theater) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment