Call Montréal, Canada 524-949-6869

Blog

Friday, October 22, 2010

Rail's ActiveRecord: include vs join

Confused when to use the :include vs. :join option? Remember these points:

  • join does not load the association into association
  • include does, it loads each association into memory
  • include is not compatible with select option
  • use include when the association is referenced
  • example use with join, doing a dynamic count on an association
  • or when the association is not referenced

Developing Ruby on Rails applications and custom Content Management Systems in Montréal. Contact Firsthand.