[PhillyOnRails] Context-Driven Validations
Aaron Blohowiak
aaron at aaronblohowiak.com
Tue Jun 12 06:59:13 MST 2007
A few times at PubNite, we have talked about validations that change
based on context.. i recently ran accross this cool solution:
http://www.lukeredpath.co.uk/2006/9/28/introduction-to-activespec
A few of us have run in to this: "On a recent project, with a
particularly complex domain model, there was the need to validate
objects in different ways, depending on its state and relationship
with other objects. We found there was a lot of pushback as we tried
to bend ActiveRecord validations to apply the complex business rules
needed. We managed it, but the resulting code wasn’t pretty and
certainly not the elegant, clear code you would come to expect from a
Ruby or Rails application. In retrospect, the Specification pattern
would have been an ideal solution."
Aaron Blohowiak
More information about the talk
mailing list