contentful_model
contentful_model copied to clipboard
How to update an entry with empty fields?
I have got a feeling that I'm missing something very basic here, please pardon me.
I have a very basic CTF model with some string attributes, some of which are not required, i.e. empty.
With return_nil_for_empty
I can have their values be coerced to nil
, but as it seems there's no way of setting them? I get NoMethodError
s for every attr_writer
to a non-required field that is blank, hence not returned by the contentful API.
Hey @julianrubisch,
If you want to write for attributes that are empty, currently the way of doing it is:
management_entry = entry.to_management
management_entry.the_empty_field = 'some value'
management_entry.save
I'll add an issue to our backlog to forward this functionality to the contentful_model
entry wrapper, so that you don't need to directly interact with the underlying management object, but cannot promise exactly when this would be completed.
Hope this workaround works for you,
Cheers
thanks, that clarifies it a little :)
Though now I'm seeing something like https://github.com/contentful/contentful_model/issues/116 ... (undefined method version= for nil:NilClass
) quite randomly...
Anything I can do to help?
Have you tried what I said in that thread?
Cheers
Yep well, it’s the same to_management method, isn’t it?
Yes, that's correct.
Cheers