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:

  1. In config/environment.rb, add the following:
    ActiveRecord::Base.pluralize_table_names = false
    

    You may have to add require 'activerecord' at the top of the file.
  2. 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.

 
---

Comment

your_ip_is_blacklisted_by sbl.spamhaus.org

---