Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Model.all有没有使用延迟加载的替代方法?我注意到返回Array而不是ActiveRecord::Relation喜欢where或order方法。
Model.all
Array
ActiveRecord::Relation
where
order
您可以使用scopedwhich 将返回一个ActiveRecord::Relation
scoped
Model.scoped
注意:在 Rails 4 中,该scoped方法已被弃用,您可以使用allwhich 返回一个ActiveRecord::Relation.
all