-
Notifications
You must be signed in to change notification settings - Fork 68
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
include_association
with array parameter overwrites existing values
#76
Comments
A reasonably terse workaround: amoeba do
include_association :foo
[:bar, :baz].each { |a| include_association a }
end |
push_value_to_array
with array parameter overwrites existing valuesinclude_association
with array parameter overwrites existing values
I assume this is also an issue for |
This is actually noted in the documentation as intended the way the DSL behaves. |
It's not at all obvious from the documentation that “original values” in
includes any previous calls to |
I suppose the author came across a situation where he wanted to override prior settings without having to go through multiple singular calls to exclude_association? Agreed it's not the most intuitive. |
It's a long story, but the model is defined in one engine, then monkey-patched in another to add a bunch more relations, some of which need to be amoeba-duplicated. |
Sounds like fun =P Did you end up using this gem despite the issues you had? |
A barrel of laughs. :) Yes, we used the |
Pull request #67 added |
Given either of the following:
@config[:includes]
takes the value[:foo, :bar, :baz]
.Given this form:
I would expect the same result, but instead the initial
[:foo]
gets overridden and the final value of@config[:includes]
is just[:bar, :baz]
.This is counterintuitive, to say the least.
(Not that you'd normally need to do this in the same file, but. We ran into it with an app that monkey-patches additional associations into a rails engine model. Including the app associations was clobbering the inclusion of the original engine associations.)
The text was updated successfully, but these errors were encountered: