instance method
cache
Ruby on Rails 4.2.9
Since v2.3.18Signature
cache(&block)
Enable the query cache within the block if Active Record is configured. If it’s not, it will execute the given block.
Parameters
-
blockblock
Source
# File activerecord/lib/active_record/query_cache.rb, line 7
def cache(&block)
if ActiveRecord::Base.connected?
connection.cache(&block)
else
yield
end
end
Defined in activerecord/lib/active_record/query_cache.rb line 7
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::QueryCache::ClassMethods