Reputation: 13715
I am developing a Ruby on Rails app and I have a model called Activity. I want to be able to make a new instance of Activity and have it be an exact copy of an existing instance of Activity, except that it has a different ID. How can I do this?
Upvotes: 0
Views: 193
Reputation: 4383
dup
will make a "shallow copy", then save the new activity.
@new_activity = @old_activity.dup
@new_activity.save
Upvotes: 5