user502052
user502052

Reputation: 15259

How can I know when\if an ActiveRecord collection is or not is lazy loaded?

I am using Ruby on Rails 3.0.10 and I would like to know whether an ActiveRecord collection (for example that generated by @user.articles) is lazy loaded or not. That is, I would like to know a "general" way to do that without reading the RoR documentation where it specifies explicitly when an ActiveRecord is lazy loaded.

How can I do that?

Upvotes: 1

Views: 186

Answers (1)

Steve
Steve

Reputation: 15736

I think you can do this with the loaded? method.

e.g.

@user.articles.loaded?

Upvotes: 1

Related Questions