Skip to content

Instantly share code, notes, and snippets.

@siannopollo
Created January 2, 2010 04:20
Show Gist options
  • Save siannopollo/267377 to your computer and use it in GitHub Desktop.
Save siannopollo/267377 to your computer and use it in GitHub Desktop.
# With a subselect
@authors = Author.find(:all, :conditions => %{id in (
select e.author_id from extensions e where e.size != 0
)})
# With the :joins key
@authors = Author.find(:all, {
:joins => 'extensions on extensions.author_id = authors.id',
:conditions => 'extensions.size != 0',
:readonly => false # Not sure why :joins key implies ":readonly => true"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment