> The default doesn't get set until the object is about to be validated, > but sometimes you need that default to be set correctly so that you > can use an object before it's either validated or saved. And are you > really suggesting that everyone should call 'valid?' on their objects > if they want them to get their correct defaults set? Default setting > belongs in the initialization phase, not in the validation phase.
You'll note that this is line two mentioned below. Your original email cited "before checked for validity", and before_validation does that. Either way, we're talking past one another here. > But 'after_initialize' implies "call this after you call the > instance's initialize method", and it's apparent that, in the case of > object retrieval, the initialize method simply isn't called (which > makes sense, because the object is only initialized once, when it got > created by calling its class's new method.) This thin and literal interpretation of the word 'initialize' makes sense only to those who care deeply about the implementation of AR. If we were to refactor Base.instantiate(record) to use .new, I'm not sure that many users would care, nor would they expect different callbacks to be called. I'm not rejecting the need for defaults beyond what the schema provides, merely suggesting that there's probably a better name out there for the callbacks to achieve that behaviour. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
