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

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

Description

@Ekkstein

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions