Last active

Changelog ActiveRecord:Base Rails 3.1

  • Download Gist
1 2 3 4 5
# ActiveRecord::Base#dup and ActiveRecord::Base#clone semantics have changed to closer match normal Ruby dup and clone semantics.
# Calling ActiveRecord::Base#clone will result in a shallow copy of the record, including copying the frozen state. No callbacks will be called.
# Calling ActiveRecord::Base#dup will duplicate the record, including calling after initialize hooks. Frozen state will not be copied, and all associations will be cleared. A duped record will return true for new_record?, have a nil id field, and is saveable.

copied_plan = test_plan.dup
copied_plan.is_shared = false
self.test_plans << copied_plan

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.