Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A little gem for Rails that provides the ability to specify attributes that will not be loaded when the record is loaded from the database, until you explicitly refer to those attributes. This is useful when you have a lot of text columns in your table; in this case lazy-loading the text attributes is a good way to lend your server a hand and cut down on database access time.
First:
gem install ar_attr_lazy
(probably as root)config.gem 'ar_attr_lazy'
to environment.rbrake gems:unpack
to vendor the gemThen, simply add an attr_lazy
line to your model, listing the attributes you want lazy-loaded. For instance:
class Post < ActiveRecord::Base
attr_lazy :body
end
Now when you do a find
, instead of doing a SELECT *
, it does e.g. SELECT id, permalink, title, created_at, updated_at
, and only when you say post.body
will it pull the body
column.
If you find a bug or have a feature request, I want to know about it! Feel free to file a Github issue, or do one better and fork the project on Github and send me a pull request or patch. Be sure to add tests if you do so, though.
You can also email me, or find me on Twitter.
http://refactormycode.com/codes/219-activerecord-lazy-attribute-loading-plugin-for-rails
(c) 2009-2010 Elliot Winkler. See LICENSE for details.
FAQs
Unknown package
We found that ar_attr_lazy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.