> It seems wasteful to begin the transactions block if the call to > #valid? simply returns false at the last minute? > Can anyone give me any insight into this system?,
I may not be correct here, I haven't checked the code, but... When you save a record for which you have built some also unsaved associated records via association.build method and similars, calling save will attempt to save all the associated records. Again, I haven't checked this, but I suspect if any associated record fails validation, all saves will be rolled back, hence the transaction. Sure you could do a lot of checks before initiating any transaction, but at some point running all the validations would become more expensive than initiating a transaction and halting it early. Also, many things can happen in ruby code, specially if you add plugins and do some metaprogramming magic. It's best for transactions to wrap all of it. > and can I start an > agrument about allowing validations to occur *before* the > transactions! Can I start an argument about premature optimization? ;P --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
