def copy_constructorThe model I am copying is "Course" and it has a N-M relation to a "Trainer" model. I use the "self.attributes" call, to set attributes on the new instance, but the relations are not copied. Also, I set "id" to nil, to make ActiveRecord think it is transient, which makes ".save" do an insert.
course = Course.new(self.attributes)
course.id = nil # make copy transient
# the "trainers" n-m relation is not copied in "new", as it is not an attribute on the model
course.trainers = self.trainers
course.trainer_ids = self.trainer_ids
Any better way to do this?