Michael K Madison
Michael K Madison

Reputation: 2209

Rails model naming partial acronym word

So. For some reason I'm struggling with Rails naming today. I feel like the best naming for a model I'm creating is DNSRecord for the camel case class model name and dns_record for snake case referencing -- Rails wants to name it DnsRecord.

I've seen a solution if the entire word is capitalized for example: API

ActiveSupport::Inflector.inflections do |inflect|
  inflect.acronym 'API' 
end

but doesn't seem to work well as:

ActiveSupport::Inflector.inflections do |inflect|
  inflect.acronym 'DNSRecord' 
end

it still wants to refer to DnsRecord. I know this is a small thing but DNSRecord feels better to me.

Upvotes: 4

Views: 730

Answers (1)

Derek Prior
Derek Prior

Reputation: 3507

I believe you will want inflect.acronym 'DNS' rather than 'DNSRecord'. You will likely also have to restart your server after updating the inflections file.

Upvotes: 6

Related Questions