#35 √ refused
Murray Steele

[patch] Support for :scope_to attributes that don't respond to .next

Reported by Murray Steele | May 20th, 2008 @ 07:45 AM

If we have attributes where the instance doesn't respond to .next (for example a Time object, or some serialized attribute that creates a Hash, or other complex Object) and we are using them to validate the uniqueness of another attribute the should_require_unique_attributes tests will fail when they attempt to call existing.send(scope).next.

This patch provides the ability to supply a :change_scoped_to_values option to should_require_unique_attributes that is a proc object which will be called instead of .next. The proc will be called with the name of the scoped attribute and the current value and the result will be used as the changed value for checking the scope.

NOTE: I've done the work for this patch and my other one (#34) in the same local branch, so this patch is based on the patch for #34. If we decide against #34 then I'll redo this one on it's own.

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

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