You can do this by setting up ActiveSupport :: Inflector , which provides titleize . Just define your own inflections in the initializer.
# config/initializers/inflections.rb ActiveSupport::Inflector.inflections do |inflect| inflect.acronym 'RV' end
Restart the application to get the changes. Now titleize knows how to handle "RV". Launch the Rails console to verify:
> "RvPark".titleize => "RV Park" > "rv".titleize => "RV"
See related documents for more interesting things you can do with kinks.
Anson
source share