开发者

can't dup NilClass - Error

I am stuck in this error for quite sometime now and have hit a dead end.

I get this totally unhelpful error

can't dup NilClass

This is the situation.

I have one class which is in a relationship with another. Say

 class Parent
 end

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

The error does not occur the first time it is accessed. It occurs the second time the child is accessed.

What is exactly causing this error and is there a solution?

I referred the following link but it doesn't help

Update

I found this

But i开发者_如何学编程t suggests the same again. But i do have a module in my lib. It Has nothing to do with the model though.


Why are you marking the Child as unloadable? Is there a good reason for this? if not, I'd remove.

Rails API says "Unloadable constants are removed each time dependencies are cleared."

Does the error happen when you change it to:

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

And, I may be overstepping, but this seems more standard:

class Child
  belongs_to :parent
end

class Parent
  has_many :children, :dependent=>:destroy
end


this is an error from the underground infrastructure. it may caused by very basic grammar error or so .

so I suggest you make sure all the config files are present(especially the config folder, those yaml files )

In my case, I solved this issue by adding the config/application.yml (which is a config file)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜