Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find should NOT preload attributes #53

Closed
msalvadores opened this issue Jan 18, 2013 · 3 comments
Closed

Find should NOT preload attributes #53

msalvadores opened this issue Jan 18, 2013 · 3 comments
Labels
Milestone

Comments

@msalvadores
Copy link
Member

For consistency with where and all and to avoid confusion and improve performance. Find might be use to see if a resource exists.

@msalvadores
Copy link
Member Author

Correct usage for find from now:

instance = Model.find("boo") 
instance.load unless instance.loaded?
puts instance.attr

the returned instance is not loaded. It is just a reference. To access the attributes one should do instance.load to be safe we can always check the loaded? flag.

Notice that find returns nil when the object cannot does not exist. This behavior was like this in previous versions.

@msalvadores
Copy link
Member Author

Changed to load attributes on find by default and an option to opt out.

Eventually find will not load the attributes and they will loaded on demand (see #62)

@graybeal
Copy link

This is either resolved, or no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants