Is there a method that works similar to singularize to prepend "a" or "an according to the word?
f(apple)
# => an applef(carpet)
#=> a carpetLook here http://deveiate.org/projects/Linguistics/wiki/English and check out this question
If you need something simpler, something that will for instance prepend "an" if a word starts with vowel, you can use my one liner:
String.class_eval { def prepend; %w(a e i o u).include?(downcase.first) ? "an #{self}" : "a #{self}"; end }
Put this in a file prepend.rb
in config/initializers
folder of your application.
Then you will be able to use
"carrot".prepend => "a carrot"
"apple".prepend => "an apple"