Skip to content

Instantly share code, notes, and snippets.

@jtrupiano
Created March 1, 2010 06:27
Show Gist options
  • Save jtrupiano/318133 to your computer and use it in GitHub Desktop.
Save jtrupiano/318133 to your computer and use it in GitHub Desktop.
named_scope :with_versions, lambda {
opts = {:joins => :versions}
ids = Version.find(:all, :select => 'rubygem_id').map(&:rubygem_id)
ids.empty? ? opts : opts.merge(:conditions => ["id IN ?", ids])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment