QuintellaRosa
2007-Oct-29 16:47 UTC
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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Oct-29 16:52 UTC
Re: Where does Rails convert "Person" to "people", "Car" to "cars"?
ActiveSupport Go find inflector.rb Jason On 10/29/07, QuintellaRosa <quintellarosa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > 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? > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-29 16:53 UTC
Re: Where does Rails convert "Person" to "people", "Car" to "cars"?
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mohit Sindhwani
2007-Oct-29 17:39 UTC
Re: Where does Rails convert "Person" to "people", "Car" to "cars"?
QuintellaRosa wrote:> 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? >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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
QuintellaRosa
2007-Oct-29 17:40 UTC
Re: Where does Rails convert "Person" to "people", "Car" to "cars"?
THANK YOU very much, both of you! On Oct 29, 2:53 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---