views:

40

answers:

1

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 gem or put it somewhere else? This will be my first gem.

+2  A: 

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
Simone Carletti
So the init.rb file can be used just like a Rails initializer? I thought it might be the case but I also wasn't sure if they happened at different stage of the boot process. I'll try that tonight
hopeless