Closed m2meier closed 1 month ago
Huh, I didn't know about config.active_record.pluralize_table_names
!
@m2meier, do you run into the same problems for Active Storage, Action Text, Action Mailbox...?
@m2meier, do you run into the same problems for Active Storage, Action Text, Action Mailbox...?
Same problem for ActiveStorage. My pull request: https://github.com/rails/rails/pull/52970. On ActionText and ActionMailbox I'm currently investigating.
Update:
ActionText and ActionMailbox have their table names fixed to plural, ignoring config.active_record.pluralize_table_names
.
I wonder why this started failing after Rails 7.1, though ๐ Did Rails handle this automatically in the past? I see the pluralize_table_names
config option has existed for way longer. Maybe this is a regression of some sort?
I wonder why this started failing after Rails 7.1, though ๐ Did Rails handle this automatically in the past? I see the
pluralize_table_names
config option has existed for way longer. Maybe this is a regression of some sort?
The option already existed when I started with Rails (v5 or earlier). But before the introduction of ActiveStorage, there were no tables that Rails created itself. And only since v7.1 does pluralize_table_names
lead to a problem with these tables.
And only since v7.1 does
pluralize_table_names
lead to a problem with these tables.
Right! So, this must be a regression of some sort. I think that's what should be addressed instead of working around it here or in the other core frameworks ๐ค
Right! So, this must be a regression of some sort. I think that's what should be addressed instead of working around it here or in the other core frameworks ๐ค
IMHO that's not a regression. Rather, the core frameworks now correctly comply with the configuration for table names and therefore static strings in (generated) migrations must be replaced by the correct, โcalculatedโ table names. But who am I to hold a strong opinion here. ๐ I will simply cancel my pull request. Never mind.
The schema definition in
db/queue_schema.rb
uses static plural table names. If rails runs withconfig.active_record.pluralize_table_names = false
, this leads to an error as soon as solid_queue tries to access the DB.The static strings for the table names in the schema definition are replaced by the
table_name
method of the corresponding model class. This ensures that the tables are named correctly in plural or singular respectively.