On Thu, May 26, 2011 at 6:23 PM, David Kahn <d...@structuralartistry.com>wrote:
> > > On Thu, May 26, 2011 at 6:06 PM, Avram Dorfman <li...@ruby-forum.com>wrote: > >> Hello, >> >> Can someone tell me how to teach the Inflector to stop treating a >> particular word as irregular that is not? >> >> I have an app that has a model named "Regatta" and another model named >> "RegattaInclusion" (which is the join model for an HMT relation. >> >> Out of the box, "regatta".singularize returns "regattum", which is not a >> word. >> >> I have tried this: >> >> ActiveSupport::Inflector.inflections do |inflect| >> # insert option here >> end >> >> With several options: >> >> 1. inflect.singular("regatta", "regatta") >> # "regatta".singularize works, but "regattas".singularize returns >> "regattas" >> 2. if I add inflect.plural("regattas", "regatta"), it works the same >> as in 1. >> 3. inflect.irregular("regatta", "regattas") >> # has no effect >> > > I am replying as I am usually the one killed on inflections. So, I found if > I include both of the below, I get good output: > > inflect.singular('regatas', 'regatta') > inflect.plural('regatta', 'regattas') > > ruby-1.8.7-p334 :001 > "regatta".pluralize > => "regattas" > ruby-1.8.7-p334 :002 > "regattas".singularize > => "regatta" > ruby-1.8.7-p334 :003 > > Sorry, did not check: ruby-1.8.7-p334 :004 > "regatta".singularize => "regattum" ruby-1.8.7-p334 :005 > So, no dice. Annoying and stange, huh? > > Does this work for you? I can also conrifm that your other examples are the > same on my environ. > > >> >> None of the tools in the Inflector::Inflections module seem to address >> this problem - a word that looks like an irregular plural, but is really >> just a normal singular. >> >> In case you are wondering why this matters, it's because I'm using >> Railroad to build an ERD, and it is giving me a fake entity called >> "Regattum" that some of my relationships are going through. If I try to >> fix it with inflections, then it crashes because Rails tells it the >> class is called "Regattas" instead of "Regatta." >> >> >> >> 1. inflect.irregular "regatta", "regattas" # "regatta".singularize >> =>"regattum" >> 2. inflect.uncountable "regattum" # >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> 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@googlegroups.com. >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.