更新时间:2023-12-01 10:40:04
我一直在使用default_scope在希望始终加载的选定模型上执行此操作:
I've been using default_scope to do it on selected models where I always want to eager load:
class Post < ActiveRecord::Base
has_many :comments
default_scope :include => :comments, :order => ["title ASC"]
...
end