Comments (5)
This comment from #11 is instructive:
The correct solution is to be able to derive a Contentful model completely from the cache but unfortunately it's harder than it seems to generate one from a webhook in the first place, because the Contentful library (used by ContentfulModel and ContentfulRails) can't instantiate an entry (or asset or whatever) from JSON - only from a call to the API.
Basically this is an unsolved problem.
My suggested / planned solution is probably to subclass ContentfulModel::Base and include some way of marshalling the whole thing into the cache. Then you could hook into the instrumentation call raised when a web hook arrives, hit the api, and update it. At the moment there is a recursion issue in the underlying Contentful library which needs working around before the marshalling will work.
from contentful_rails.
@edtjones & @zrisher there is a way that would allow to create an entry without a making an api call:
https://gist.github.com/neonichu/17a987aeeb256d4bf6f3
this is a bit hackish. I think it would make sense to open a ticket at
https://github.com/contentful/contentful.rb
and discuss this there. It would be a huge benefit to improve caching if this was possible.
from contentful_rails.
This has been solved for over a year. Closing.
from contentful_rails.
I encountered a problem recently that required me to do the Marshal.dump/Marshal.load trick. I have a content model that includes references to other pieces of content. The first time my content is put in the rails cache, it's fine. But the second time, when reading the cached entry, one of the properties is returned as a Contentful::Link instead of a Contentful::Asset.
If I do Marshal dump/load the content is a Contentful::Link always. I can then resolve the link, but of course I'd love to avoid that resolve call.
Apologies though: I just realized this may not be the place for my comment, since I'm using the Contentful API directly.
from contentful_rails.
Hey @swetonic,
I have identified this issue and I'm currently working on fixing it, it happens when doing Marshal.load
on objects which previously had unpublished nested resources.
The inclusion errors were not serlialized, therefore the links were being displayed instead of removed from the result.
I'll be publishing a fix today on the https://github.com/contentful/contentful.rb gem.
Cheers
from contentful_rails.
Related Issues (20)
- Concern with `eager_load!` HOT 14
- Subclassing MarkdownRenderer HOT 5
- Missing attr_writer for attributes with nil values HOT 3
- #delete_matched not supported by all ActiveSupport cache types HOT 2
- alias_method_chain call in timestamps.rb causes deprecation warning HOT 4
- this thing work? HOT 10
- Rails 5 support? HOT 1
- enable caching support HOT 7
- Can't load gem without ActiveRecord HOT 6
- Webhooks Rails 5 HOT 6
- Webhooks fail in Rails 5.1 HOT 2
- Content types caching blowing up VCR on CI HOT 1
- Release webhooks fix? HOT 1
- Load error HOT 5
- Support Contentful Model 1.0 HOT 2
- OOM errors in Docker HOT 9
- Webhook Engine does not provide the /debug route as expected HOT 1
- How do you perform the russian nesting doll cache?
- "Only Redis glob strings are supported: " on unpublish when using redis as cache store
- Eager load in a to_prepare block
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contentful_rails.