Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Gem for Rails that lets you specify attributes that will not be loaded when you do a find until you refer to those attributes. Great for speeding up your app if your table has a lot of text/blob columns. [ABANDONED]

License

mcmire/ar_attr_lazy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ar_attr_lazy

Summary

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.

Installation/Usage

First:

  1. Run gem install ar_attr_lazy (probably as root)
  2. Add config.gem 'ar_attr_lazy' to environment.rb
  3. Optionally run rake gems:unpack to vendor the gem

Then, 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.

Support

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.

Inspiration

http://refactormycode.com/codes/219-activerecord-lazy-attribute-loading-plugin-for-rails

Author/License

(c) 2009-2010 Elliot Winkler. See LICENSE for details.

About

Gem for Rails that lets you specify attributes that will not be loaded when you do a find until you refer to those attributes. Great for speeding up your app if your table has a lot of text/blob columns. [ABANDONED]

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages