Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Rails 7.1 Error when reading active record model from redis cache

$
0
0

We have a problem during upgrade Rails from 7.0.8 to 7.1.3.2 with reading AR models from Redis cache.

We have several places where we cache AR models with Redis:

Rails.cache.fetch("key_name") { Ar_Model[some_key] }

After Rails upgrade we can't read all params (except id) from model. Example:

Run two same consoles.In one of them:

model = Rails.cache.fetch("key_name") { Ar_Model[some_key] }model.class => Ar_Model(id: integer, name: string)model.name => "some_name"

But in the second console:

model = Rails.cache.fetch("key_name")model.class => Ar_Model(id: integer, name: string)model.id => some_idmodel.name => Error! Unknown method 'name' for Ar_Model()

Interestingly, after run, for example, Ar_Model.first in the second console, we can read all params from model without any reloading.

model = Rails.cache.fetch("key_name")model.class => Ar_Model(id: integer, name: string)model.id => some_idmodel.name => Error! Unknown method 'name' for Ar_Model()Ar_Model.firstmodel.name => "some_name"

Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>