Closed niquepa closed 6 years ago
I have the same Issue reported in contentful.rb https://github.com/contentful/contentful.rb/issues/138
have this issue currently but it only appears when we put a cache on an object. When I receive this object from contentful directly I get an Asset when it's a cache hit I sometimes get an Asset but some other time I get a Link. This is quite apparent because out of a collection of two things one has an image of type Asset while the second has an image of type Link.
Hi @niquepa,
Can you let me know which version of the integration and SDK you are using?
This issue has been fixed almost a year ago. The contentful_model
integration has been recently updated to version 1.x
which includes all the new updates to the SDKs.
Cheers
Hi @dlitvakb I'm including master branch:
gem 'contentful_model', :git => 'https://github.com/contentful/contentful_model.git', :branch => 'master'
checking the Gemfile.lock seems like I'm using v0.2.0:
remote: https://github.com/contentful/contentful_model.git
revision: 660bf1bbd499387a04c25e1f6fdbf8f0000c2beb
branch: master
specs:
contentful_model (0.2.0)
activesupport
contentful (~> 2.0)
contentful-management (~> 1.0)
redcarpet
Should I use v1.0.0 ?
Hey @niquepa,
Please try updating to use 1.0.0
, as the dependencies listed seem outdated.
Cheers
This is how my Gemfile.lock looks now:
GIT
remote: https://github.com/contentful/contentful_model.git
revision: 91b89361d85c310c42eefbf3c08cbbf372dcd3ad
specs:
contentful_model (1.0.0)
activesupport
contentful (~> 2.7)
contentful-management (~> 2.0)
redcarpet
but the error stills present. The way I get the content from contentful is:
@professionals = Rails.cache.fetch(:"professionals_#{I18n.locale}", expires_in: ENV['cache_ttl'].to_i) do
Web::Dentist.all.params({'order' => 'fields.orden', 'locale' => I18n.locale}).load.items
end
Web::Dentist class is just 3 lines of code:
class Web::Dentist < ContentfulModel::Base
self.content_type_id = "dentist"
end
The weird thing is that the first element always has the proper relation as ContentfulModel::Asset
but the other elements have ContentfulModel::Link
- professionals.each do |dentist|
.item
.thumbnail
- if !dentist.fotos.blank? && dentist.fotos.first
%img{:alt => "", :src => dentist.fotos.first.try(:url)}/
As you can see in the below images, that happens for all the relations, the specialty is not loaded either:
Thanks for your help
Hey @niquepa,
Can you create a support request here https://support.contentful.com
requesting for me and provide me your Space ID and CDA Token? This looks like a possible bug, but I cannot know for sure unless I test it further.
Cheers
I have the following code to get some entries from contentful:
each entry has a relation to an asset (picture), so I'm accessing it like:
It works without any problem and if you inspect each picture you'll see:
but if I try to cache the response like this:
and then iterate the entries, only the first item has the relation as Contentful::Asset, the rest of items have Contenful::Link, if you inspect each entry you'll see:
So it throws an error, again it only happens when you cache the response, I'm using memcached for it.