Reputation: 545
I am trying to understand the initialization process for Rails 3 plugins. I have a plugin packaged as a gem that I am including in my Gemfile for my project.
In turn, that gem specifies in its gemspec that it depends Sunspot::Rails. The gem itself gets pulled in and I can access its classes, but it doesn't appear that the railtie initialization code gets run.
However, if I add a line in my project's Gemfile for sunspot_rails directly, then the initialization code is run.
Does anyone know of a way to have my gem/plugin run the initialize code in its dependencies without having to include all of them directly in my project?
Thanks in advance.
Upvotes: 2
Views: 346
Reputation: 545
After reading the above article and responses, I realized that I was requiring sunspot/rails
instead of sunspot_rails
. It's necessary to require sunspot_rails
because that in turn requires the railtie (which is not automatically required as part of having the gem listed in the gemspec).
Here is a link to a very good article on the difference between gemspec and Gemfile that helped explain it all.
Upvotes: 1