Skip to content

Instantly share code, notes, and snippets.

@mrbrdo
Last active August 29, 2015 14:10
Show Gist options
  • Save mrbrdo/12ecabd4a6ff11db07b5 to your computer and use it in GitHub Desktop.
Save mrbrdo/12ecabd4a6ff11db07b5 to your computer and use it in GitHub Desktop.
sequel eager loading with conditions
artists = Artist.eager(songs: ->(q) { q.where{year > 1990} }).all
# example to illustrate the results
artists.each do |artist|
puts "Artist: #{artist.name}"
puts "Songs since 1990: " + artist.songs.map(&:title).join(", ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment