Comments (14)
The test suite is being run on TravisCI using rails 5.0.0.1 and passes. Which version are you exactly talking about?
from deep_cloneable.
5.0.0.1
same, but my locals specs pass on Rails 4.2 and don't pass on 5
I am using 2.2.2 version
from deep_cloneable.
It might have to do with the new rails defaults for belongs_to. But I'm not sure. Do you think you can come up with a failing test case?
from deep_cloneable.
@moiristo
From what I see, there is another validation in Rails 5:
I've tried to debug here
lib/deep_cloneable.rb:88
kopy.associations.map(&:association_field)
(where associations
is just a has many relation)
[nil, nil, nil, nil]
same in Rails 4 and 5
But kopy.associations.map(&:valid?)
Rails 4:
[true, true, true, true]
Rails 5:
[false, false, false, false]
That's why it says not a number
, 'cause it's nil
from deep_cloneable.
adding config.active_record.belongs_to_required_by_default = false
into config didn't solve the problem
from deep_cloneable.
So it tells you that the associated objects are not valid. What are the errors? Can you do something like: kopy.associations.map{|record| record.valid?; record.errors.full_messages.join(',') }
and see what the validation errors are?
from deep_cloneable.
@details={:association_id=>[{:error=>:not_a_number, :value=>nil}]},
@messages={:association_id=>["is not a number"]}
from deep_cloneable.
Ok, so kopy.associations
points to a certain list of objects that contain a belongs_to
somewhere that is stored in association_id
. Does it work when you make that belongs_to
optional?
from deep_cloneable.
Added optional: true
to belongs_to
relation, it doesn't work as well,
btw I have belongs_to
with params class_name
and foreign_key
if it matters...
from deep_cloneable.
Hmm, it might be that rails5 handles things differently when nil
is explicitly being passed to an association. Just a hunch.. I'll try to find out if I can reproduce the error in the test suite.
from deep_cloneable.
Doing the same on new rails 5 project
from deep_cloneable.
👍 please let me know when you know more!
from deep_cloneable.
After deeper digging into the problem I've seen it's my custom validation fails, sorry for that...
thanks for the gem, btw
from deep_cloneable.
Ok, thanks for the feedback!
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.