David Dumaresq
2006-Aug-24 15:14 UTC
[Rails] Something to consider when strange words appear in error messages
I was having a problem running a test using a fixture called receives. The error was class "Receife" not found. Being new at this it took me a while to figure out that I needed an inflection rule, because receives was being inflected to receife and then classify camelcased it into Receife.>> "receives".singularize => "receife" >> "receives".classify => "Receife"I suspect the two rules responsible for this are: # C:\ruby\lib\ruby\gems\1.8\gems\activesupport-1.3.1\lib\active_support\inflections.rb # inflect.plural(/(?:([^f])fe|([lr])f)$/i, ''\1\2ves'') # inflect.singular(/([^f])ves$/i, ''\1fe'') In my environment.rb, I tried creating a simple plural and singular rule, but they didn''t make any difference. I ended up creating an irregular rule, which worked fine. (Probably a DRYer solution anyway) but I''m not sure why the rules didn''t work. Inflector.inflections do |inflect| # inflect.plural ''/^(receive)$/i'', ''\1s'' # inflect.singular ''/^(receive)s/i'', ''\1'' inflect.irregular ''receive'', ''receives'' end Anyway, I hope this helps you avoid some unnecessary head scratching! Regards, Dave Dumaresq _______________________________ Information and Educational Technology Kwantlen University College "So powerful is the light of unity that it can illuminate the whole earth." --Bahá''u''lláh --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---