Contextual validations with associations

3 views
Skip to first unread message

MarkMT

unread,
Oct 24, 2009, 2:53:39 AM10/24/09
to DataMapper
I'm in the process of using contextual validations for the first time,
and I've discovered that if I save an object that has children, the
children will be saved with the same context as the primary object.
However, if there's no validation declared for the child with that
particular context, an exception will be raised.

I can see that if the child has a validation defined for the context
specified when the primary object is saved, then it absolutely makes
sense to run that. But it's not clear to me that you should actually
be required to have a validation defined on the child for that
context. And if the child doesn't actually require validation, I guess
you would have to add a validates_with_block with an empty block.

Is this the intended behavior, or something worth changing?

Mark.

Fluxx

unread,
Nov 16, 2009, 1:43:35 AM11/16/09
to DataMapper
This bit me just now too. It seems to happen even if you say "has
n, :through => Resource," and try to save the parent with a context.
It appears to be requiring the parent's context to exist on the join
modelI'm currently on Datamapper 0.10.0.

Is this the expected behavior?

-J

Jeff Pollard

unread,
Nov 18, 2009, 5:23:24 PM11/18/09
to DataMapper
Sorry to bump this thread, but it's currently blocking our migration to 0.10.x, which we'd really like to be on.  If this is the expected behavior, that is an okay thing, we just need to know if that's the case :)

Thanks,

-J

--

You received this message because you are subscribed to the Google Groups "DataMapper" group.
To post to this group, send email to datam...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/datamapper?hl=.



Reply all
Reply to author
Forward
0 new messages