Open jits opened 5 years ago
Hey, thanks for report. Will check it when will have time (hope on new years holidays) 👍
So, I found the root cause of the issue.
We are defining all mandatory attributes and only after it we are creating nested classes.
So, in this step ->
https://github.com/davydovanton/shallow_attributes/blob/master/lib/shallow_attributes/type.rb#L80
we have mandatory attributes for User, but we call .new
without args and it threw an exception.
I haven't ideas how to fix it properly, just thoughts.
We have two ways:
Class.new
with params
@jits @davydovanton WDYT ?@X1ting – nice find. To be honest, I'm not sure I fully understand the impact, but your option (2) sounds like it makes the most sense and is in line with how shallow_attributes
expects objects to be initialised (i.e. all required data must be provided at object initialisation). Having the nested objects initialised in the same way makes a lot of sense.
Let me know if there's something I can help further with.
Hi – firstly, thank you for this library!
I've noticed that using
present: true
on embedded values throws an error (seemingly every time).To reproduce: if you add
, present: true
to https://github.com/davydovanton/shallow_attributes/blob/9a9c55eacf25343489c456a9d979d91ac54bc573/test/custom_types_test.rb#L6 the test will fail with error messages like:I may be able to take a closer look and work on a PR when I have more time; any pointers are gladly welcome.