I running into an issue with the Rails.cache methods on 3.1.0.rc4 (ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10]). The code works fine within the same applic
I realized that using where or some scope created ActiveRecord::Relation objects. I then noticed that doing a simple Model.find worked. I suspected that it didn't like the ActiveRecord::Relation object so I forced conversion to a plain Array and that worked for me.
Rails.cache.fetch([self.id, 'relA']) do
relA.where(
attr1: 'some_value'
).order(
'attr2 DESC'
).includes(
:rel_1,
:rel_2
).decorate.to_a
end