Comments (6)
@tinderfields try to remove cost_timespans
from clone and include_association and use only clone [:costs]
from amoeba.
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.
Yes, clone will automatically include all
from amoeba.
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.
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.
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)
- What licence should amoeba have
- `nullify` on a not-null column should set to default value HOT 1
- Regex preprocessing of field fails on null value
- `amoeba_dup` on rich_text field raises `NoMethodError: undefined method 'macro' on nil:NilClass` HOT 4
- Passing params into the amoeba function? HOT 2
- include_association also including other association, Which are not supposed to be included
- Consider implementing autoload for Active Support HOT 4
- Add checking for invalid configuration
- What is the difference between `customize` and `override`?
- Remove deprecated second argument on serialize option in class used in tests
- The default inclusive/exclusive style is so confusing...
- Trying to clone with has_many through association
- Using append on associated records.
- Inter dependant structure HOT 2
- Is it possible to use a dynamic value in this set block ?
- Does it work with Rails 6? HOT 3
- has_many dupes do not set belongs_to in memory HOT 2
- Is this gem abandoned? HOT 3
- How can I "move" has_many association instead of copy?
- Association custom query HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amoeba.