#445 ✓resolved
Mirko Froehlich

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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Attachments

Pages