是否可以在rabl视图中进行片段缓存?

Nie*_*ian 6 api caching ruby-on-rails rabl

我正在尝试做这样的事情:

cache "api/v1/cars_index/#{I18n.locale}/car/#{car.cache_key}" do
  attributes :id, :brand, :model_name, :fuel, :km, :year, :price
  node(:color) { |car| car.color.present? ? car.color : '' }
end
Run Code Online (Sandbox Code Playgroud)

Lis*_*nge 3

对于那些通过搜索或谷歌找到这个问题的人。

Niels 在 Github 上发起了一个问题,可以在此处找到。

开发人员为此创建了一个出色的解决方案,自 v0.6.2 起已将其合并到 rabl 中。