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

namespaces and table name relationships #19

Open
curtis741 opened this issue Jan 23, 2024 · 1 comment
Open

namespaces and table name relationships #19

curtis741 opened this issue Jan 23, 2024 · 1 comment

Comments

@curtis741
Copy link

Using the example from the README, I'd expect a model with a name of Component1::Model1 to map to a tablename of component1_model1s. Outside of the Packwerk approach, that would normally be achieved by creating this in app/model/component1.rb :

module Component1
  self.table_name_prefix = "component1"
end

Then a everything would line up correctly between the tablename (component1_model1s) and the class name of Component1::Model1. However when trying to apply that to my local codebase, Rails is complaining that it can't find a table named model1s when it should be looking for component1_model1s.

I'm not really sure how you'd inject that. Maybe the metadata could also tie in an dynamic table_name_prefix value?

I could make a base active_record class for each pack we've got and set it up that way. It just feels like there should be a better way to do this.

dvanderbeek added a commit to dvanderbeek/automatic_namespaces that referenced this issue Jan 23, 2024
@gap777
Copy link
Owner

gap777 commented Nov 13, 2024

@dvanderbeek On our project, we made a base active_record class for each pack, and set the table name prefix there. I'm not keen on assuming that the class is an AR model, nor that it lives in models (as opposed to models/filters or models/metrics or models/reviews/, etc.).

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

2 participants