Ruby on Rails
Turn (Version #6)

It would be nice if there was an option to disable the pluralization in the heuristic used to map Ruby class names to database table names. This can be undesirable:

  • You don’t want to use plurals for table names
  • You don’t want to use English in the names of classes or tables
  • Even if you do want plural, and use English in your code, the default English plural will be incorrect in many cases, and you may not want to bother overwriting those.

This seem to be enough:


def (ActiveRecord::Base).table_name
name # or whatever transformation you want.
end

If you want to change the default for just a group of classes you can do:

for c in [MyClass,Other,Other2]
def c.table_name
name #or whatever
end
end

GabrieleRenzi

Alternatively, you can turn it all off at once using this code:

ActiveRecord::Base.pluralize_table_names = false

It works if put in the “Environment Specific Configuration” section of /config/environment.rb .

It would be nice if there was an option to disable the pluralization in the heuristic used to map Ruby class names to database table names. This can be undesirable:

  • You don’t want to use plurals for table names
  • You don’t want to use English in the names of classes or tables
  • Even if you do want plural, and use English in your code, the default English plural will be incorrect in many cases, and you may not want to bother overwriting those.

This seem to be enough:


def (ActiveRecord::Base).table_name
name # or whatever transformation you want.
end

If you want to change the default for just a group of classes you can do:

for c in [MyClass,Other,Other2]
def c.table_name
name #or whatever
end
end

GabrieleRenzi

Alternatively, you can turn it all off at once using this code:

ActiveRecord::Base.pluralize_table_names = false

It works if put in the “Environment Specific Configuration” section of /config/environment.rb .