moped icon indicating copy to clipboard operation
moped copied to clipboard

NoMethodError: undefined method `relations' for Card:Class

Open Ekkstein opened this issue 8 years ago • 0 comments

Hello, I will be brief to save time. I hope you can help me. For development reasons I am trying to monkey patch a model class >Card< inside a script file dev.rb which i am trying to load from the pry console. I am receiving this error:

NoMethodError: undefined method `relations' for Card:Class

It was happening irregularly and I finally noticed, that if I try to monkey patch it before some call to the Card class was issued, the error shows up. If I just insert a call to Card right before the patching, it works. I don't know if I am missing something here, or if this is intended behaviour that I am ignorant about. Thank you!

Update: I tried to reproduce once again and suddenly the error has changed. I receive: NoMethodError: undefined method `first' for Card:Class when trying to receive the first entry from the database after I loaded the dev.rb file with the monkey patch. Again, issuing a call to Card before loading the script prevents the error. This seems like some sort of lazy loading that I don't know about.

Ekkstein avatar Mar 28 '17 02:03 Ekkstein