Where do you preload associations?

Another way to do it is to not to use preload altogether. Just create views that include the association at the db level and treat them as separate schemas in ecto. So you will have the following schemas:

  • class, which maps to the table
  • class_with_users, which maps to the view that joins class and users

Then you just have different context functions as usual.