2 ms·
ActiveRecord is far from straightforward when it comes to joins, unfortunately. Even if you use belongs_to/has_many you still have to manually perform the join
by ratww 7y ago
ActiveRecord is far from straightforward when it comes to joins, unfortunately.
Even if you use belongs_to/has_many you still have to manually perform the join, otherwise you'll get an N+1 issue which will affect your performance. On top of that there are four ways to perform that join: joins(:table), include(:table), eager_load(:table) or preload(:table).
In SQL you can basically achieve the same level of expressiveness by using NATURAL JOIN.