Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

NoMethodError: undefined method `relations' for Card:Class #401

Open
Ekkstein opened this issue Mar 28, 2017 · 0 comments
Open

NoMethodError: undefined method `relations' for Card:Class #401

Ekkstein opened this issue Mar 28, 2017 · 0 comments

Comments

@Ekkstein
Copy link

Ekkstein commented Mar 28, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant