Suppose I have two models A and B
Now I want to copy some information from an instance of A to an instance of B by clicking a button
Is there a way of doing it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This process is called cloning an object and the complexity of it depends on what kind of information you would like to clone.
If you simply want to clone an object’s fields, you would do something like this:
If, however, you want to also clone the old object’s associations, you will need to do that by hand.
Say for the sake of argument that
Ahad ahas_manyassociation ofBobjects calledbees, andBhas_manyCobjects calledsees, this could get a little complex: