technoweenie / active_record_context

simple identity map for active record. eager loading associations FTL

This URL has Read+Write access

technoweenie (author)
Fri Nov 23 12:29:46 -0800 2007
commit  65ba031b72c445e6e382faa93277fbf5bc71132b
tree    61820bc4810a723653a5ccc20ab3ed62a53c3981
parent  53307381cc6ae0ce3a4783ea732570bfaa9fe3c8
name age message
file README Sun Nov 26 00:21:19 -0800 2006 add logging git-svn-id: http://svn.techno-ween... [technoweenie]
file Rakefile Sat Nov 25 22:50:21 -0800 2006 add active_record_context plugin git-svn-id: h... [technoweenie]
file init.rb Sat Sep 29 11:21:22 -0700 2007 add support for reload git-svn-id: http://svn.... [technoweenie]
directory lib/ Fri Nov 23 12:29:46 -0800 2007 add #destroy support git-svn-id: http://svn.te... [technoweenie]
directory test/ Sat Sep 29 11:21:22 -0700 2007 add support for reload git-svn-id: http://svn.... [technoweenie]
README
ActiveRecordContext
===================

Simple ActiveRecord context for caching AR objects.  It caches all records from #find queries
that aren't readonly, and that don't have eagerly loaded associations. It only looks in the context
on simple Foo.find(id) queries with no conditions.  It's designed to work as an alternative to eager
loading associations.  It will also help all the extra find calls for models that access their associations
in callbacks/validations.

It only uses the context when it's activated.  To activate, you can set a controller around_filter:

  around_filter :set_context
  
  def set_context
    ActiveRecord::Base.with_context do
      yield
    end
  end
  
Set Technoweenie::ActiveRecordContext.log_context_activity = true to turn on debug logging.