Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
preload associations with find_by_sql
# http://cha1tanya.com/2013/10/26/preload-associations-with-find-by-sql.html
# Rails4 way
@users = User.find_by_sql(some_condition)
ActiveRecord::Associations::Preloader.new.preload(@users, :company)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.