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 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, May 26, 2011 at 6:06 PM, Avram Dorfman <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, May 26, 2011 at 6:23 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org>wrote:> > > On Thu, May 26, 2011 at 6:06 PM, Avram Dorfman <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> ruby-1.8.7-p334 :004 > "regatta".singularize > => "regattum" > ruby-1.8.7-p334 :005 > > > So, no dice. Annoying and stange, huh?RIght, no dice. At this point I have wrapped the Inflections module to manually return the correct results for "regatta" and "regattas" and then just call back to the original for anything else. That is actually working, but oh-my-god is it a stupid ridiculous hack to have to put into place. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, May 26, 2011 at 11:26 PM, Avram Dorfman <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> > ruby-1.8.7-p334 :004 > "regatta".singularize > > => "regattum" > > ruby-1.8.7-p334 :005 > > > > > So, no dice. Annoying and stange, huh? > > RIght, no dice. > > At this point I have wrapped the Inflections module to manually return > the correct results for "regatta" and "regattas" and then just call back > to the original for anything else. That is actually working, but > oh-my-god is it a stupid ridiculous hack to have to put into place. >Yeah, when I saw your email and I did also start poking around in active support > inflections and it just makes no sense. If you add a rule supposedly it should take precedence to all existing code. The only thing I could come up with is that Inflections thinks that ''regatta'' is a plural and for some reason that decision takes precedence over any rule added. I know it may not make sense for you but I would consider changing the name of the model just to please Inflections..... how about ''SailBoatRace''?... we can go the way of euphanisms to avoid irregulars :)> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m glad to see other people also punt instead of making the inflections make sense. I wasted a bit of time trying to create a scaffold named "Series" and just changed it to "SeriesObj" so I could start working on my web site.> Yeah, when I saw your email and I did also start poking around in active > support > inflections and it just makes no sense. If you add a rule > supposedly it should take precedence to all existing code. The only thing I > could come up with is that Inflections thinks that ''regatta'' is a plural and > for some reason that decision takes precedence over any rule added. I know > it may not make sense for you but I would consider changing the name of the > model just to please Inflections..... how about ''SailBoatRace''?... we can go > the way of euphanisms to avoid irregulars :)-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.