I'm trying to use fragment caching with Jbuilder as one of the view is taking quite a bit to render (only view rendering can take 2500ms+
Note that this does work in other calls, but this one can't seem to work and I can't figure why. Second : this works on my local machine but fails in heroku.
Here is the error in heroku :
2013-09-18T21:05:46.425034+00:00 app[web.1]: Rendered api/shop/products/_product.json.jbuilder (3.2ms)
2013-09-18T21:05:46.606141+00:00 app[web.1]: Marshalling error for key 'shop/products/344-20130914175034924266000/shop/products/346-20130914175035358419000/shop/products/345-20130914175035153905000/en/b5262bbbd44fb696ffdece67a464e218': no _dump_data is defined for class Proc
2013-09-18T21:05:46.606141+00:00 app[web.1]: You are trying to cache a Ruby object which cannot be serialized to memcached.
2013-09-18T21:05:46.606141+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/dalli-2.6.4/lib/dalli/server.rb:397:in `dump'
2013-09-18T21:05:46.606141+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/dalli-2.6.4/lib/dalli/server.rb:397:in `serialize'
2013-09-18T21:05:46.606141+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/dalli-2.6.4/lib/dalli/server.rb:269:in `set'
2013-09-18T21:05:46.606141+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/dalli-2.6.4/lib/dalli/server.rb:60:in `request'
2013-09-18T21:05:46.606141+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/dalli-2.6.4/lib/dalli/options.rb:18:in `block in request'
Here's the simple part where I tried to use the fragment cache:
json.cache! [category[:products], I18n.locale] do
json.products category[:products] do |product|
json.partial! product
end
end
And the product partial :
json.(
product,
:id,
:name,
:picture,
:price,
:subcategory
)
json.product_options product.product_options do |option|
json.(
option,
:id,
:name,
:option_type
)
json.option_items option.product_option_items do |item|
json.(
item,
:id,
:name
)
end
end
json.partial! 'api/app_styles/app_style', app_style: product.app_style
So after some deep digging, I finally discovered that it is a problem with
With the combination of those 3 things + using the paperclip object instead of the url (i.e json.node_name my_model.paperclip_attached_file instead of json.node_name my_model.paperclip_attached_file.url) made it fails.
Now seems to work faiirly…
So Matthew were right on target saying that the picture was the problematic one, but only with rails_stdout_gem + paperclip S3 config