Looks like inflections don't work for module names with the nesting level more than one.
If you have the following in your config/initializers/inflections.rb:
ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym 'VCloud'
end
Then when you create a directory under app/, say app/services/vcloud/ you will get two modules:
Vcloud #=> Vcloud
VCloud #=> VCloud
But if you create a directory with a higher nesting level, say app/services/vmware/vcloud/ you will get only one module:
Vmware::Vcloud #=> Vmware::Vcloud
Vmware::VCloud #=> NameError: uninitialized constant Vmware::VCloud
Is this a bug?
I would go with this is a bug. You can go around it with (within initializers):
module ActiveSupport::Inflector
def underscore_with_acronym_fix(string)
words = string.split('::')
return words.map(&method(:underscore)).join('/') unless words.one?
underscore_without_acronym_fix(string)
end
alias_method_chain :underscore, :acronym_fix
end
I'll make a pull request to fix this, however will need slightly more time to confirm it will not break anything. There are quite a lot of cases here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With