COMPLEX WEB APPS MADE SIMPLE

written by PrimeHammer

Tag: Ruby on Rails

Playing with “joins” in ActiveRecord

Published by Ivan
4 min read

On many occasions we need to load multiple records with associations from a database. The easiest way is to access this is via iteration (.each) written in Ruby. This is not the best approach as it can result in issuing 1+n queries (complexity O(n)) instead of single query (O(1)). Using iteration isn’t optimal because as the […]