
Validation error when creating resource with one-to-many association
Reported by Mirko Froehlich | July 7th, 2008 @ 01:58 PM
I have two resources, A and B, and a one-to-many association between them. In addition, B uses validates_present to ensure that the foreign key for A is specified.
When I try to create a new A object by passing in a hash that includes one or more new B instances, I would expect the create call to set up the necessary associations and correctly save A as well as the associated B instances. In fact this is how it used to work with the DM edge version from around 6/30/08.
As of today (7/7/08), this results in a validation error for B (but not A), stating that B's belongs_to property cannot be nil.
I can comment the validates_present out for now, since I normally create / update B instances through their associated A instance anyway, but I would prefer to add the validation back in, just to ensure that B objects ultimately are never saved to the db without an associated A object.
Comments and changes to this ticket
-
Jonathan Stott (namelessjon) November 30th, 2008 @ 08:12 AM
- State changed from new to hold
- Assigned user cleared.
I'm fairly certain this is fixed in dkubb/dm-core, but not sure, so placing it on hold
-
Dan Kubb (dkubb) January 8th, 2009 @ 04:53 AM
- State changed from hold to accepted
- Assigned user set to Dan Kubb (dkubb)
-
Jonathan Stott (namelessjon) February 22nd, 2009 @ 07:47 AM
- Tag changed from belongs_to, bug, dm-more, validations to belongs_to, bug, dm-more, one_file_test, validations
- State changed from accepted to resolved
Using dm-core 0.10.0 and dm-validations 0.10.0 this works.
See attached one file test.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »