Cannot duplicate NilClass - Error

I’ve been stuck with this error for quite some time and am at a standstill.

I get this absolutely useless error

can't dup NilClass 

This is the situation.

I have one class that is in a relationship with another. Let's say

  class Parent end class Child < Parent unloadable :has_many :parents, :foreign_key => "child" end 

Error on first access does not occur. This happens the second time they are accessed.

What exactly causes this error and is there a solution?

I referenced the following link , but this does not help

Update

I found this one

But he offers the same thing again. But I have a module in my library. This has nothing to do with the model.

+4
source share
1 answer

Why do you mark a child as non-paged? Is there a good reason for this? if not, I would delete.

The Rails API says that "Unloadable constants are removed each time a dependency is released."

Whether an error occurred while changing it:

 class Child < Parent has_many :parents, :foreign_key => "child" end 

And, I can step over, but this seems more standard:

 class Child belongs_to :parent end class Parent has_many :children, :dependent=>:destroy end 
+2
source

Source: https://habr.com/ru/post/1316122/


All Articles