I would like to do a deep copy on objects including all the attributes.
The experiment_old is has 10 trials. And I want to copy everything to experiment_new with the 10
You should clone every trial and assign them to the cloned experiment:
@experiment_new = @experiment_old.clone @experiment_old.trials.each do |trial| @experiment_new.trials << trial.clone end