RailsCasts Pro episodes are now free!

Learn more or hide this

Toby Ovod-Everett's Profile

GitHub User: tovodeverett

Site: http://tovodeverett.wordpress.com/

Comments by Toby Ovod-Everett

Avatar

My understanding is that calling singularize before classify is redundant and can lead to problems with singular forms that end with "s". See http://apidock.com/rails/ActiveSupport/Inflector/classify and http://apidock.com/rails/ActiveSupport/Inflector/camelize. To be safe, classify should only be called on a plural form. The camelize method can be called on either and will return a result with the same grammatical number (i.e. singular or plural). Of note, the source for classify (at least in 3.2.8) is:

ruby
camelize(singularize(table_name.to_s.sub(/.*\./, '')))

Repeated calls to singularize are not necessarily safe:

ruby
"businesses".singularize # => "business"
"business".singularize   # => "busines"
"busines".singularize    # => "busine"
"busine".singularize     # => "busine"