Skip to content

Instantly share code, notes, and snippets.

@mrbrdo
Last active December 23, 2015 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbrdo/6700549 to your computer and use it in GitHub Desktop.
Save mrbrdo/6700549 to your computer and use it in GitHub Desktop.
class Person < ActiveRecord::Base
has_many :photos
has_one :display_photo, class_name: "Photo"
end
# WARNING: This only appears to work properly!
people = Person.all.includes(:display_photo)
people.each { |person| puts person.display_photo.id }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment