The dashed version is for extensions on other frameworks, like rspec-rails
and the underscore is for part of the normal gem name and should be camelcased in your classes.
So if you have a gem named foo_bar
, the class/module should be named FooBar
. If that gem should have a rails extension which ships as a different gem, it should be called foo_bar-rails
and the module should be called FooBar::Rails
and it should be required as require "foo_bar/rails"
This convention is also what Bundler tries to require.
Admittedly, this convention is not always followed. jquery_rails
should actually be jquery-rails
and factory_girl_rails
should be called factory_girl-rails
. But hey, not everything is perfect.
RubyGems convention docs:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…