Where does Rails convert "Person" to "people", "Car" to "cars"?

We know Rails convert “Car” to “cars” when creating tables and so. Or,
“Person” to “people”. So, I’m sure there are rules that apply to “Car”
and there are data to particular cases like “Person”.

Being brazilian, modeling a database in Portuguese doesn’t work well
on Rails. I know enough to develop it in English, but I must develop a
particular database in Portuguese, so others can read it “natively”…

So, my question: where’s this database containing “Person”. If I find
it, I can include the rules for Portuguese and the exceptional words
into the database. Does someone know where they are?

ActiveSupport

Go find inflector.rb

Jason

On 29 Oct 2007, at 16:47, QuintellaRosa wrote:

So, my question: where’s this database containing “Person”. If I find
it, I can include the rules for Portuguese and the exceptional words
into the database. Does someone know where they are?

This is the job of the inflector. You can customise these mappings, eg

Inflector.inflections do |inflect|
inflect.plural /^(ox)$/i, ‘\1en’
inflect.singular /^(ox)en/i, ‘\1’
inflect.irregular ‘person’, ‘people’
inflect.uncountable %w( fish sheep )
end

(this is straight from example stuff in environment.rb)

You proabably want to replace the whole thing, the default set are in
activesupport/lib/active_support/inflections.rb

Fred

THANK YOU very much, both of you!

On Oct 29, 2:53 pm, Frederick C. [email protected]

QuintellaRosa wrote:

into the database. Does someone know where they are?

You are looking for a way to define or use custom inflections. This
will get you started.
http://devchix.com/2006/09/25/how-to-add-customized-plural-singular-word-pairs-in-rails/

By the way, you can also consider a non-traditional schema as being a
“legacy” schema and use some of the tips and tricks mentioned here:
http://wiki.rubyonrails.org/rails/pages/HowToUseLegacySchemas

Hope this helps.

Cheers,
Mohit.
10/30/2007 | 1:39 AM.