Created
May 26, 2012 14:12
-
-
Save bom-d-van/2794090 to your computer and use it in GitHub Desktop.
the simplest way to clone or duplicate an ar record in rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/60033/what-is-the-easiest-way-to-duplicate-an-activerecord-record | |
# rails < 3.1 | |
new_record = old_record.clone | |
#rails >= 3.1 | |
new_record = old_record.dup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment