Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong table annotations for models with same name, but different tables #674

Open
jimmytang opened this issue Oct 17, 2019 · 2 comments
Open

Comments

@jimmytang
Copy link

Describe your problem here.
Two different models, both with the same class name. One is inside a Rails engine inside the app, the other inside the main rails app. They are pointing to different underlying PostGres tables.

When running model annotations, both models show the annotations for the model inside the main app.

The expected result should be the model inside the main app has annotations representing it's underlying table and the model inside the engine has a different set of annotations representing it's underlying table.

Commands

rake db:update_model_annotations

Version

  • annotate version
    2.7.5
  • rails version
    5.2.3
  • ruby version
    2.6.2p47
@maxh
Copy link

maxh commented Feb 5, 2020

Looks like a fix for this might be adding an explicit self.table_name = "foo_bar" to one of the models.

drwl pushed a commit that referenced this issue May 8, 2020
Currently, the models annotator automatically attempts to find a class with a matching name at the bottom of project's directory tree before going up into specific engine's models.  This causes issues with models that share names with classes in other engines or lower classes in the project's directory.   This PR adds the option to skip attempts to load classes from lower directories and just uses the model's file path directly. 

#674
@MGPalmer
Copy link

Looks like a fix for this might be adding an explicit self.table_name = "foo_bar" to one of the models.

We've got the same issue, and this doesn't work for us :(

ocarta-l pushed a commit to ocarta-l/annotate_models that referenced this issue Jun 18, 2021
Currently, the models annotator automatically attempts to find a class with a matching name at the bottom of project's directory tree before going up into specific engine's models.  This causes issues with models that share names with classes in other engines or lower classes in the project's directory.   This PR adds the option to skip attempts to load classes from lower directories and just uses the model's file path directly. 

ctran#674
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants