Override all table names in ActiveRecord

My project does not use multiple convention in table names. How can I override this convention without calling set_table_name in the entire ActiveRecord class

+4
source share
2 answers

You need to create an initializer in the rails project, for example:

# file: config/initializers/active_record_extensions.rb ActiveRecord::Base.pluralize_table_names = false 

This will cause all your table names to be unique by default on your models.

+6
source

If these are only specific tables, and not all of them

self.pluralize_table_names = false

works good.

+1
source

Source: https://habr.com/ru/post/1301028/


All Articles