Validation behaviour scope

hi everyone, in this http://pastie.org/271218 example I'm going to do some basic stuff.

I'm trying to add an existing object to a collection; the issue here is that :on => :create fires not only on Reason create but even when adding a Reason to a collection.

I was thinking that it should be scoped/isolated Reason objects.

Any thoughts about this behaviour?

kain

Claudio Poli wrote:

hi everyone, in this http://pastie.org/271218 example I'm going to do some basic stuff.

I'm trying to add an existing object to a collection; the issue here is that :on => :create fires not only on Reason create but even when adding a Reason to a collection.

I was thinking that it should be scoped/isolated Reason objects.

Any thoughts about this behaviour?

It's certainly counter-intuitive and looks like a bug to me.

Is it a has_many :through association you're using? If so it's probably because the 'through model' is being :create d and the validations are looking at that instead of the lifecycle of the Reason object.