CachedModel looks for a specific SQL query when deciding whether or not to cache a record. For single row finds, ActiveRecord
no longer uses "LIMIT 1", which is part of the SQL that CachedModel looks for. Thus, nothing is ever cached.
An initial fix is to remove "limit 1" from cached_model.rb line 149 (I think this would be backwards compatible
with older versions of Rails). A more robust fix would be to look for the ActiveRecord version (1.15.1) and specify
the corresponding query to match.
def self.find_by_sql(*args)
return super unless args.first =~ /^SELECT \* FROM #{table_name} WHERE \(#{table_name}\.#{primary_key} = '?(\d+)'?\)
+LIMIT 1/
|