I just read http://www.stephenchu.com/2008/05/rails-composedof... article... twice. He does a great job, but what I find really ugly (so not Rails) is when I want to use ActiveRecord:Validations module in my Value Object - I need to "stub out" some of the inner plumbing to pretend I am really an ActiveRecord object. Is this the best way to integrate Value Objects from aggregations into Rails validation and error reporting? My googling so far turns up more questions than answers. The docs such as: http://api.rubyonrails.org/classes/ActiveRecord/Ag... talk about a lot but not about validation. Please show me there is a more elegant, DRY, declarative way to realize this than lots of custom code or the module inclusion pattern written up by Steve Chu. Thanks...
on 2009-04-04 16:18
on 2009-04-04 23:52
Work around - validate the component fields as they exist in the containing class. In some cases this is better for my needs - but in other cases it may be not as useful. It fits the way Rails works and for now is the best I can do.