ActiveRecord

Rails5 ActiveRecord で select をする時の高速化便利関数

select 高速化のヒント class Parent has_many :childs end class Child belongs_to :parent end has_many の配列データ側を絞り込む。なければ parent も返らない。 Parent.includes(:childs).where("childs.age > ?", 20).references(:childs) belongs_to …