Skip to content

Instantly share code, notes, and snippets.

@kylefox
Created January 22, 2010 18:44
Show Gist options
  • Select an option

  • Save kylefox/284020 to your computer and use it in GitHub Desktop.

Select an option

Save kylefox/284020 to your computer and use it in GitHub Desktop.
# Assume a Post belongs to a Blog.
# Django does this with one SQL statement:
posts = Post.objects.filter(blog__name="My Blog")
# Rails:
posts = Blog.find_by_name("My Blog").posts
# Rails?
posts = Post.where(:blog__name => 'My Blog')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment