A Quick Note on 'clone' in Rails 3.2
Feb 08, 2013 06:59

I recently upgraded one of my business apps from Rails 2.1 to Rails 3.2, and I discovered a sneaky and dangerous 'gotcha':

ActiveRecord in Rails 3.2 doesn't support the 'clone' method anymore. The official replacement method is called 'dup'.

This wouldn't be a big problem, except that you can still call 'clone' on an ActiveRecord model and instead of throwing an error, it returns the original object. This means that as of Rails 3, 'clone' does exactly the wrong thing.

Of course, your 100% test coverage should catch that ... right?

Previous:
My eBook Apps 2: iOS, JavaScript, and Ruby
Sep 12, 2012 06:21