Skip to content

Instantly share code, notes, and snippets.

@bulters
Created June 3, 2010 10:31
Show Gist options
  • Save bulters/423721 to your computer and use it in GitHub Desktop.
Save bulters/423721 to your computer and use it in GitHub Desktop.
named_scope :magic, lambda {
{
:joins => "INNER JOIN airings ON airings.id=spotlights.object_id INNER JOIN episodes ON episodes.id=airings.episode_id",
:conditions => ["object_type='Airing' AND airings.ends_at < ? AND episodes.video IS NOT NULL", DateTime.now.utc],
:order => "airings.ends_at DESC",
:group => "airings.id"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment