You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm having issues with the referencing of a specific model when being cloned. I've tried using multiple approaches but none have gotten the correct result, and I believe it has to do with me not understanding how the logic of cloning works.
This involves multiple models, but the error raises in an interdependency between the last 2 models in the hierarchy. For simplicity, I'll try to explain this with 3 models to get an idea of how everything's working: Page, PageElement and PageElementDependency
A Page has many PageElements
A PageElement has many dependent_page_element_dependencies and has_many dependee_page_element_dependencies, where both of these relations are PageElementDependency. Through both of these dependencies I've setup the following has_many through relationships: has_many :dependees, through: :dependent_page_element_dependencies and has_many :dependents, through: :dependee_page_element_dependencies. Summarizing everything looks like this:
Let's say I'm trying to clone Page#3, with PageElement#4 and PageElement#5, where there's a PageElementDependency, where the dependent is PageElement#4 and the dependee (who is depended upon) is PageElement#5.
So basically here we'd be able to access PageElement.find(5).dependees => PageElement#6, and if I do PageElement.find(6).dependents => PageElement#5.
So, when trying to clone Page#3, I'd expected to get a new Page#4 with PageElement#6 and PageElement#7, and here's the important part, a PageElementDependency where the dependent is PageElement#6 and the dependee is PageElement#7.
However, when I try cloning the PageElementDependencies, only one of the columns is getting a new value, but the other column is keeping the old PageElement's value. So in the example given, I'd get a PageElementDependency where the dependee is correct: PageElement#6, but the dependent is not update and stays as PageElement#5.
I'm not sure how to use a remapper in order to get the related "new" and "old" object of the dependencies, so I'm not really sure how to proceed.
Hello, I'm having issues with the referencing of a specific model when being cloned. I've tried using multiple approaches but none have gotten the correct result, and I believe it has to do with me not understanding how the logic of cloning works.
This involves multiple models, but the error raises in an interdependency between the last 2 models in the hierarchy. For simplicity, I'll try to explain this with 3 models to get an idea of how everything's working: Page, PageElement and PageElementDependency
Page
has manyPageElements
PageElement
has manydependent_page_element_dependencies
and has_manydependee_page_element_dependencies
, where both of these relations arePageElementDependency
. Through both of these dependencies I've setup the following has_many through relationships:has_many :dependees, through: :dependent_page_element_dependencies
andhas_many :dependents, through: :dependee_page_element_dependencies
. Summarizing everything looks like this:Let's say I'm trying to clone Page#3, with PageElement#4 and PageElement#5, where there's a PageElementDependency, where the dependent is PageElement#4 and the dependee (who is depended upon) is PageElement#5.
So basically here we'd be able to access
PageElement.find(5).dependees
=>PageElement#6
, and if I doPageElement.find(6).dependents
=>PageElement#5
.So, when trying to clone Page#3, I'd expected to get a new Page#4 with PageElement#6 and PageElement#7, and here's the important part, a PageElementDependency where the dependent is PageElement#6 and the dependee is PageElement#7.
However, when I try cloning the PageElementDependencies, only one of the columns is getting a new value, but the other column is keeping the old PageElement's value. So in the example given, I'd get a PageElementDependency where the dependee is correct: PageElement#6, but the dependent is not update and stays as PageElement#5.
I'm not sure how to use a remapper in order to get the related "new" and "old" object of the dependencies, so I'm not really sure how to proceed.
I've also posted this as an issue in stackoverflow: https://stackoverflow.com/questions/56811683/rails-cloning-with-amoeba-gem
The text was updated successfully, but these errors were encountered: