Hi, I submitted a patch (for the first time) a couple of days ago (http://dev.rubyonrails.org/ticket/5091 - the decsription is included below).
I've noticed some posts to rails-core notifying the world of patches, since there's been no activity on said patch I thought I'd do the same. Please let me know if this breaks protocol. Cheers, Ian White --- patch summary Summary: extra option :allow_nil for composed_of allows nil attributes in aggregations. Currently aggregations do not allow nil attributes. This means that if you want an optional aggregation in your model you must code this into your component class. This is, in most cases, a defect. For example, you may want an optional gps_location in your customer model. Currently this means you must allow for calls like GpsLocation?.new(nil), which, given the domain, does not make much sense. Better for the aggregating model to not create a GpsLocation? when there's a nil attribute. And, if your customer has just left for the moon, you want to set gps_location to nil. Currently this will result in an error. The desired behaviour would be to set the appropriate attribute(s) to nil. However, the above behaviour may not be desirable in all cases. Sometimes initializing the Component with nil does make sense. To resolve this I've created a patch which allows an option :allow_nil => true to be specified with composed_of. If this is not specified, the behaviour of aggregations remains unchanged. With :allow_nil => true the following behaviour is added. * if aggregation attributes are all nil, then nil is returned from the reader * if nil is passed to the writer then all aggregation attributes are set to nil. I've supplied a modifed aggregation_test.rb and fixtures with the patch. _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core