kryzhovnik
kryzhovnik

Reputation: 26

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

How can I get ActiveRecord::Relation object of the model without any conditions? Of cause I can write

User.where # without any args

, but thats looks confusing

Upvotes: 0

Views: 446

Answers (1)

Paige Ruten
Paige Ruten

Reputation: 176743

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

Upvotes: 3

Related Questions