automatic_namespaces icon indicating copy to clipboard operation
automatic_namespaces copied to clipboard

namespaces and table name relationships

Open curtis741 opened this issue 1 year ago • 0 comments

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.

curtis741 avatar Jan 23 '24 22:01 curtis741