How should I package up reusable extensions across multiple projects
We have some business specific extensions to common gems such as Sunspot. These extensions need to be run on startup since th开发者_如何转开发e files they belong are already defined.. ie rails will not try to autoload these because their constants have been defined. To solve this loading problem we have but these files in config/initializers/extensions.
First off, is this ideal?
Secondly (and more importantly), how can/should we package up these extensions/overrides so we can reuse them in other projects that we have? As of right now we are cut & copying the files across the projects... yuck.
Thanks for you help
I'd put the extensions in a gem. Then provide a small api call you can put in an initializer to load the gem's functionality if necessary. I don't know that you'll be able to get away from the use of an initializer, but by putting the meat of the functionality in a gem you'll at least have an easy way to share it across projects.
精彩评论