Anton Ivanov wrote:
> Hi,

> this (in class Project):
> def copy(other_project)
>   other_project.issues.each do |other_issue|
>     self.issues << other_issue.copy
>   end
>   self.save
> end
> 

Not tested.. just thinking..

Get the link(associative) table that's used in the many to many 
association and then make sure it has a first class model sitting on top 
of that so you can work with that exclusively..
Try:

def copy(other_project)
  other_project.issues.each do |other_issue|
    Issue_projects.new(:issue => other_issue.copy, :project => 
self).save();
  end
end

I believe that the memory requirements will be lower as the self will 
not be adding onto it's current issues during the copy..


ilan



-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to