Skip to content

Instantly share code, notes, and snippets.

@jbbarth
Created September 12, 2012 01:14
Show Gist options
  • Save jbbarth/3703454 to your computer and use it in GitHub Desktop.
Save jbbarth/3703454 to your computer and use it in GitHub Desktop.
ActiveRecord, has_many :include, has_many :through
class User < ActiveRecord::Base
has_many :memberships, :include => :roles
has_many :projects, :through => :memberships
end
User.first.memberships
#=> eager loads "roles"
User.first.projects
#=> does NOT eager loads "roles"
# Conclusion: ":through" does not takes intermediate relations' ":include" options
# Right ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment