cache_method icon indicating copy to clipboard operation
cache_method copied to clipboard

Suggestion for Readme - caching a class method

Open jamesr2323 opened this issue 9 years ago • 0 comments

I was scratching my head for a while as to how to cache a class method. I figured out that you can do it by calling cache_method on a method inside a singleton class definition. Perhaps this is obvious to others but maybe worth adding to Readme. E.g.

class Blog < ActiveRecord::Base
    class << self
         def method_want_to_cache
               ...
         end
         cache_method :method_want_to_cache

    end
end

jamesr2323 avatar Dec 06 '15 18:12 jamesr2323