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

improvements to "nested attributes" #139

Closed
jrochkind opened this issue Jan 11, 2022 · 1 comment
Closed

improvements to "nested attributes" #139

jrochkind opened this issue Jan 11, 2022 · 1 comment

Comments

@jrochkind
Copy link
Owner

jrochkind commented Jan 11, 2022

This confusing to talk/think about. But some things have been a bit inconvenient with form handling, that we can possibly take care of with our _attributes= methods, which are of course pretty much just there for form handling (I think?), via Rails analogy for associations using _attributes= methods.

  • if i have a nested object on a form, and ALL it's inputs are left empty, I really want to remove it from the DB, not leave it in the DB with all empty-string attributes
  • for a single (not array) embedded model... if I leave all the inputs empty, I want to DELETE it, not just leave it there empty
  • For a single (not array) embedded model, an easier way to make a form taht automatically "builds" it when needed?

Not sure if these would be universal wants. Or if they'd need to be configurable somehow.

In general, to "solve" this I'd want to spend some more time testing what Rails does in "ordinary" circumstances, including to_many and has_one inline editing... if possible, it would be nice to match rails, but if what Rails does is too un-helpful, we coudl maybe do better/different.

@jrochkind
Copy link
Owner Author

OK, we're not going to do anything else with this right now. #175 took a stab off it.

We might in the future do something with a "normalization" API; in AttrJson v2 the upcoming Rails 7.1 normalizes feature should actually work with AttrJson::Record attributes, so would be one way to strip empty strings. As it won't for now be useable in non-ActiveRecord ActiveModel classes... we may want to provide something similar in the future ourselves. It's not going to be in 2.0.

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

No branches or pull requests

1 participant