Skip to content

Instantly share code, notes, and snippets.

@MaxPleaner
Last active December 31, 2016 00:00
Show Gist options
  • Save MaxPleaner/3d2607036a8cab9a48b5f6fcb600e0ae to your computer and use it in GitHub Desktop.
Save MaxPleaner/3d2607036a8cab9a48b5f6fcb600e0ae to your computer and use it in GitHub Desktop.
active record preload_map
class ActiveRecord::Query
def preload_map(association_name_sym)
preload(association_name_sym).map &association_name_sym
end
alias map_with_preload preload_map
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment