Interesting, thanks, lots of tricks there I wouldn'thave figured out for myself. But am I being really inefficient now by calling to_yaml an extra time? I'll call it once to validate, and then throw away the results. Then serialize will call it again when it actually wants to save. Calling it twice for no reason. But I guess to_yaml shouldn't be _that_ expensive?
Now I wonder if I should abandon the automated serialization altogether, and just handle it myself manually through callbacks. Or maybe I should try monkey-patching the auto-serialization stuff to perform this check itself? Jonathan Mark Reginald James wrote: > Jonathan Rochkind wrote: >> But obviously, if a yaml serialization gets truncated, it's not going to >> unserialize very well. >> >> At the point of insert/update, is there any good way for me to detect >> that the serialization was too big for the column, even though MySQL >> isn't complaining? > > This may do it: > > def validate > if columnName.to_yaml > column_for_attribute(:columnName).limit > errors.add(:columnName, 'columnName is too big to be serialized') > end > end > > It'd be good if something like this was added automatically by > serialize. > > -- > Rails Wheels - Find Plugins, List & Sell Plugins - > http://railswheels.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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-talk?hl=en -~----------~----~----~----~------~----~------~--~---

