I want to write a custom ActiveRecord cache, just for `find_by_id` right now.
To do that I want to overwrite the find method, when just a single int is given use my cache, otherwise use the default implementation.

```
class X < ActiveRecord::Base
    def self.find(*args)
        return XCache[args[0]] if args.size == 1 && args[0].is_a?(Numeric)
        return super.find(*args)
    end
end

```

Everything works find except for the case of an association I have with other instances of X, e.g. a parent-child relationship:

```
has_many :x_children
has_many :children, :class_name => "X", :through => :x_children

```

When I call `X.find(1).children` I get an `Enumerator` instead of an `Array`, which is bad since I sometimes use the [] operator.

Even using the enumerator doesn't work well - when iterating the last entry I get:

```
NoMethodError: undefined method `call' for :all:Symbol

```

Any help will be highly appreciated

Further explanation:

XCache is just a class that caches instances of ActiveRecord.
A simplistic implementation can be

```
class XCache
    @@cache = {}
    def self.[id]
        return @@cache[id] ||= X.find(id)
    end
end

```

(A more advanced implementation can include expiration time, Memcached etc., and a more generic solution can support multiple model classes).

I don't think my problem is related to the cache implementation (but I might be wrong)