Closed d11wtq closed 13 years ago
Alternatively, if I duplicate the actual legacy field name 'subjectid' in the :child_key
option, this works, however the behaviour of DM allows my other way for specifying associations (it cuts down on repetition) so I guess dm-validations should behave that way too.
It's also odd, but this behaviour isn't observable in a real-life test; it only becomes a problem in my functional tests.
I realised what was happening. It was my fault and I only stumbled upon it as I started working through all of my models, replacing :child_key
definitions with the actual field name, not the alias. When I got to the User
model, I noticed that I had mis-typed :child_key => [:subjectid]
(without the underscore). I wasn't expecting the culprit to be in the parent model, but I'll know to always check both sides of the association in future. Consider this closed! ;)
Given this model for a legacy schema:
For some reason, this isn't validating, with the cryptic error message of "Subjectid must not be blank":
While this is validating (passing the legacy field name directly):
It's interesting that it's only the
:subject
property that falls victim to the bug and that:user
works fine (presumably because the key name is predictable).