Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update an entry with empty fields? #123

Open
julianrubisch opened this issue Oct 9, 2018 · 5 comments
Open

How to update an entry with empty fields? #123

julianrubisch opened this issue Oct 9, 2018 · 5 comments

Comments

@julianrubisch
Copy link

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 NoMethodErrors for every attr_writer to a non-required field that is blank, hence not returned by the contentful API.

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 9, 2018

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

@julianrubisch
Copy link
Author

thanks, that clarifies it a little :)

Though now I'm seeing something like #116 ... (undefined method version= for nil:NilClass) quite randomly...

Anything I can do to help?

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 9, 2018

Have you tried what I said in that thread?

Cheers

@julianrubisch
Copy link
Author

Yep well, it’s the same to_management method, isn’t it?

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 9, 2018

Yes, that's correct.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants