Closed dsounded closed 7 years ago
The test suite is being run on TravisCI using rails 5.0.0.1 and passes. Which version are you exactly talking about?
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
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?
@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
adding config.active_record.belongs_to_required_by_default = false
into config didn't solve the problem
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?
@details={:association_id=>[{:error=>:not_a_number, :value=>nil}]},
@messages={:association_id=>["is not a number"]}
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?
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...
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.
Doing the same on new rails 5 project
👍 please let me know when you know more!
After deeper digging into the problem I've seen it's my custom validation fails, sorry for that...
thanks for the gem, btw
Ok, thanks for the feedback!
I have troubles with Rails 5 and postgres:
foreign key field is not a number and some other fields are invalid
, any ballpark date for Rails 5 compatibility ?