Giter Club home page Giter Club logo

Comments (6)

simonoff avatar simonoff commented on August 28, 2024

@tinderfields try to remove cost_timespans from clone and include_association and use only clone [:costs]

from amoeba.

tinderfields avatar tinderfields commented on August 28, 2024

Ok, it now looks like this:

amoeba do
  include_association :available_services
  include_association :sign_cancellation_charges
  include_association :costs

  clone [:costs]

  customize ->(original_client, new_client) {
    new_client.service_ids = original_client.service_ids
    new_client.assign_attributes new_client.attributes.select { |k, v| k.ends_with?('_count') }.inject({}) { |h, (k, v)| h[k] = 0; h }
  }
end

It's difficult to say exactly what happens when I do this, but it seems to be attempting to clone every association on client, certainly it is looping through every other association type - does clone automatically include everything?

from amoeba.

simonoff avatar simonoff commented on August 28, 2024

Yes, clone will automatically include all

from amoeba.

tinderfields avatar tinderfields commented on August 28, 2024

Is there any way to prevent this behaviour, at the moment I've got this, but its still trying to clone everything

amoeba do
  clone [:costs]

  exclude_association %i(...)

  include_association :available_services
  include_association :sign_cancellation_charges
  include_association :costs

  customize ->(original_client, new_client) {
    new_client.service_ids = original_client.service_ids
    new_client.assign_attributes new_client.attributes.select { |k, v| k.ends_with?('_count') }.inject({}) { |h, (k, v)| h[k] = 0; h }
  }
end

from amoeba.

simonoff avatar simonoff commented on August 28, 2024

Then you need to put specific amoeba block in your costs.
But in any case you cannot use clone and include_association for same associations.

from amoeba.

MichaelSp avatar MichaelSp commented on August 28, 2024

I have a similar issue because of the behaviour in exclude_association:

@config[:includes] = []

now if I use clone the apply_associations falls back to follow_all. But I want to clone and have includes.

from amoeba.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.