开发者

Rails 3 'where' with no conditions or 'all' lazy loading

开发者 https://www.devze.com 2023-01-07 09:14 出处:网络
How can I get ActiveRecord::Relat开发者_运维知识库ion object of the model without any conditions?

How can I get ActiveRecord::Relat开发者_运维知识库ion object of the model without any conditions? Of cause I can write

User.where # without any args

, but thats looks confusing


User.scoped will do it. All methods like where, order, limit, etc. are delegated to scoped. Calling it directly gives you the bare Relation.

0

精彩评论

暂无评论...
验证码 换一张
取 消