Customizing Active Storage Tables: Namespace Configuration?

This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.

Anyone tried to customize the active storage tables to namespace them? instead of active_storage_blobs, I’d like it to be namespaced to core_ext__active_storage_blobs Anyone know if active storage is thusly configurable?

Message originally sent by slack user U717GMJTWHJ

I don’t know off the top of my head, but you can probably make it that way with a little Ruby tomfoolery.

Message originally sent by slack user U717GMJTWHJ

A quick googling isn’t finding anything, but with enough code, anything is possible.

I’m not so sure….

activestorage-7.0.4.1/app/models/active_storage/blob.rb:

self.table_name = "active_storage_blobs"

Message originally sent by slack user U717GMJTWHJ

You can always override that and change just that line or create a new class that subclasses it and that sets a different table name.

Message originally sent by slack user U717GMJTWHJ

With ruby, all bad ideas are possible.

Message originally sent by slack user U717GMJTWHJ

Like, you could create the migration, edit it before you run it to change the table name, then create an initializer that just overrides self.table_name and you’re done.

Message originally sent by slack user U717GMJTWHJ

Do I know if that’s a good idea? Not at all. But am I pretty sure you could make it work? Totally.