jnunemaker/mongomapper — pull request #363 by statianzo (2011-12-12 21:12:11+00:00)
Title: validates_associated context limitations

Currently, `validates_associated` always validates against a nil context when invoking the association's `valid?` method. This is a limitation if you want to validate the association is a different context.

Always passing through the context from the root's `valid?(context)` would wind up with `:create` and `:update` getting passed to the association. That has the possibility of strange behavior (ie. when the association is new and the root is not).

Instead, a possible solution is to allow a `:context` option to be set on the `validates_associated` call.

validates_associated :user, :context => :vip

While this doesn't have the flexibility of allowing a per-`valid?` call context, it at least provides a way to use an alternative validation context on associations.