Can't dup NilClass on association methods

后端 未结 2 1001
悲&欢浪女
悲&欢浪女 2021-01-14 12:23

I\'m using rails 2.3.5 and ruby 1.8.7. I\'m building a simple TODO manager. Where I have tasks that belong to a user and a user has many tasks.

I\'m using act

相关标签:
2条回答
  • 2021-01-14 12:48

    Maybe there is something wrong with associations in model. Can you paste some code from there?

    You can also try doing the same in console. Does it give the same error? Take a look in logs, do both of your examples generates the same sql query?

    0 讨论(0)
  • 2021-01-14 13:01

    Got it.

    From here,

    Some of the classes inherited or included in your engine controllers may fail to get unloaded and cause trouble after the first request to your system.

    For me, it was because I had a file in the lib that was monkey patching User model and the User model class in this file was not getting cached I suppose.

    Calling unloadable in that class in the lib folder did the trick. So my lib file looks like this

    class User < ActiveRecord::Base
      unloadable
      # stuff...
    end
    

    Thanks anyways.

    0 讨论(0)
提交回复
热议问题