Tell Rails not to Use Plural in Table Names
The tables I am working with do not have an “s” at the end of their end. This link explains how to tell Rails that your tables should not be pluralized, rather than using set_table_name
in every single model classes:
- In
config/environment.rb
, add the following:
ActiveRecord::Base.pluralize_table_names = false
You may have to addrequire 'activerecord'
at the top of the file. - For exceptions, you can obviously still use
set_table_name
:
class Post < ActiveRecord::Base set_table_name "posts" end
In my quest for singularization, I also came across this link which deals with plurals, albeit in a different context.