开发者

Where does the Rails initializer go in a gem?

开发者 https://www.devze.com 2022-12-21 02:55 出处:网络
I\'m trying to extract some functionality from my existing app into a gem. The existing functionality uses an initializer to load up a config file when Rails starts up...

I'm trying to extract some functionality from my existing app into a gem. The existing functionality uses an initializer to load up a config file when Rails starts up...

config/initalizers/myinitializer.rb

Where should this initializer go in the gem? Do I mirror the path structure inside the ge开发者_运维知识库m or put it somewhere else? This will be my first gem.


When the Gem is loaded, Rails first looks for a file called init.rb in the main Gem folder and requires it if available.

This can be a super-simple base skeleton for a Rails plugin packages as Gem:

name
name/lib
name/lib/name.rb
name/test
name/init.rb
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号