public
Description: simple identity map for active record. eager loading associations FTL
Clone URL: git://github.com/technoweenie/active_record_context.git
Click here to lend your support to: active_record_context and make a donation at www.pledgie.com !
technoweenie (author)
Sat Nov 25 23:33:38 -0800 2006
commit  239e3da70a266de8079c54a29020bc8e1092026f
tree    e6f44212097e71aed9e4c00b4a747e45b71d15c2
parent  2c267883690e1dfa3df5a5545537b5c86ebf1ac8
name age message
file README Sat Nov 25 22:50:21 -0800 2006 add active_record_context plugin [technoweenie]
file Rakefile Sat Nov 25 22:50:21 -0800 2006 add active_record_context plugin [technoweenie]
file init.rb Sat Nov 25 22:50:21 -0800 2006 add active_record_context plugin [technoweenie]
directory lib/ Sat Nov 25 22:50:21 -0800 2006 add active_record_context plugin [technoweenie]
directory test/ Sat Nov 25 23:33:38 -0800 2006 add tests for belongs_to/polymorphic associations [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