Last active
August 29, 2015 14:10
-
-
Save mrbrdo/12ecabd4a6ff11db07b5 to your computer and use it in GitHub Desktop.
sequel eager loading with conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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