How to avoid downcasing acronyms in ruby / rails -


i have field contains titles "it professional" or "db administrator". want display in middle of sentence , need down-case. unfortunately, downcases acronyms , end "thanks joining community of professionals".

a start solution mentioned grantovich below, i.e. specifying acronyms in config/initializers/inflections.rb:

activesupport::inflector.inflections |inflect|   inflect.acronym "it"   inflect.acronym "db" end 

the problem going route firstly, don't want store them in lower case suggested part of solution because titles , should stored capitals. secondly, defined in uppercase , bad idea make them lower case.

solution found: since want title appear in middle of sentence, hence need lower case, solved downcasing title, constructing sentence , calling #humanize on that. humanize capitalize first letter of sentence , defined acronyms.

if possible, store strings "it professional", "db administrator", etc. letters except acronyms downcased. can add acronyms inflector , use #titleize convert title case when needed. in terms of edge cases , code maintenance burden, better solution writing own code "selective downcasing".


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -