You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
dvanderbeek
added a commit
to dvanderbeek/automatic_namespaces
that referenced
this issue
Jan 23, 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.).
Using the example from the README, I'd expect a model with a name of
Component1::Model1
to map to a tablename ofcomponent1_model1s
. Outside of the Packwerk approach, that would normally be achieved by creating this inapp/model/component1.rb
:Then a everything would line up correctly between the tablename (
component1_model1s
) and the class name ofComponent1::Model1
. However when trying to apply that to my local codebase, Rails is complaining that it can't find a table namedmodel1s
when it should be looking forcomponent1_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.
The text was updated successfully, but these errors were encountered: