Comments (5)
You're follow_up
association looks a bit mangled, what's going on there?
follow_up
ishas_many
, therefore it should befollow_ups
, or it should be ahas_one
association instead- A follow_up is a
Question
? Then why is its foreign key id calledparent_option_id
?
What actually happens (I think) is the following:
- An
Option
record is found and cloned - The
follow_up
association is found and cloned - In the cloned
FollowUp
, deep_cloneable passes the cloned option to the inverse association (should be something likebelongs_to :option, inverse_of: :follow_up
in follow_up) - For some reason, AR expects a collection of objects instead of a single
Option
object. That's what the error shows. Therefore I think your associations are not correctly specified.
from deep_cloneable.
follow_up
is a naming problem that I inherited with this code base, I know it's not correct.
A follow_up
is a question that belongs to an option. Options have two associations with Questions- one as a belongs_to
, and one as has_many
. The other side of that is
Question belongs_to :option, :foreign_key => "parent_option_id", inverse_of: :follow_up
The foreign key is stored on Question.
from deep_cloneable.
Ok, I need to reproduce the error in the test suite first in order to fix it. I'll try to add one shortly.. unless you'd like to give it a try yourself of course ;)
from deep_cloneable.
I should be able to do that this afternoon…
On Sep 13, 2016, at 12:12 PM, Reinier de Lange [email protected] wrote:
Ok, I need to reproduce the error in the test suite first in order to fix it. I'll try to add one shortly.. unless you'd like to give it a try yourself of course ;)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #67 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AAM3e8imrYqFU82P5OAtKj4mMI4oeEXbks5qpvWdgaJpZM4J7DFl.
from deep_cloneable.
This should be fixed by #71 (release 2.2.2).
from deep_cloneable.
Related Issues (20)
- rails 4 deep_clone different in development/staging and production HOT 2
- deep_clone not called on has_many_through relation HOT 4
- How to handle :has_rich_text associations in rails 6 HOT 3
- include:do loop also modified the includes HOT 1
- How To Attach Polymorphic Associated Records To A Different Model? HOT 2
- Error: private method `open' called for #<ActiveStorage::Attached::Many HOT 20
- Options argument hash for deep_clone is modified HOT 2
- Question: How to deep clone classes associated to the same class, as in a linked list or tree? HOT 1
- Conditional nested includes HOT 2
- Include all associations without having to specify all of them? HOT 1
- 3.1.0 is not released to rubygems.org? HOT 2
- Using deep clone to extract a subset db from production HOT 2
- Possible unexpected has_and_belongs_to_many behaviour. HOT 2
- Add support for Rails 7
- deep_clone has issues with acts_as_tenant gem how we can make it work ? HOT 1
- Add support for Mongoid HOT 1
- How to handle multiple parents? HOT 1
- Not possible to exclude attribute named 'rank' HOT 2
- Fix documentation for Active Storage usage in Rails 6.1
- problem with counter_cache 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 deep_cloneable.