Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child records not getting updated with proper reference Id. #73

Open
personalworker opened this issue Sep 19, 2016 · 0 comments
Open

Child records not getting updated with proper reference Id. #73

personalworker opened this issue Sep 19, 2016 · 0 comments

Comments

@personalworker
Copy link

Hi All,
I have the following models

  class Bmc < ActiveRecord::Base
     has_many :segments
     has_many :value_propositions
     has_many :relationships
     amoeba do
        enable
     end
  end

  class Segment < ActiveRecord::Base
    has_one :value_proposition
    has_and_belongs_to_many :relationships
    amoeba do
       recognize [:has_one, :has_and_belongs_to_many]
    end
  end

  class ValueProposition < ActiveRecord::Base
    belongs_to :bmc
   belongs_to :segment
    amoeba do
       recognize :belongs_to
    end
  end

  class Relationship < ActiveRecord::Base
    belongs_to :bmc
    has_and_belongs_to_many :segments
    amoeba do
       recognize :has_and_belongs_to_many
    end
  end

In my controller I'm doing

 bmc_copy =  Bmc.find(id).amoeba_dup
 bmc_copy.save.

I wanted to duplicate the records recursively when I dup the bmc. But for some reason segment_id(s) not getting updated properly in relationship and value_proposition tables, when i save the bmc_copy(original segment id(s) is getting copied as-is and not the duplicated sendment's id).

Can someone help me where am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant