I’ve got an engine that utilizes the savon gem. When I run the dummy application in /test inside the engine, it all works out just fine, but when I try to mount and run it as an engine inside my application, I get the error:
`require': no such file to load -- savon (LoadError)
I used to include it by adding require "savon" to the top of the model, soap_model.rb that uses it. According to this post I shouldn’t add it to the model, but the environment.rb. It did’t seem like the environment.rb was run while starting the server, as it just produced a new error
uninitialized constant EngineName::SOAP::Savon
So I added it to an initializer, which yields the same error when trying to start the server with rails s.
Environment:
Mac OS 10.7.3
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.3.0]
Rails 3.1.4
savon (0.9.9)
Note: I have of course made sure that bundle install runs correctly, and restarted the server.
The gem was included in the engines Gemfile, but not added as a dependency in the gemspec, thus it was not included when
bundle installwas run in the main app.Adding this to
enginename.gemspecmade everything work.
The reason it worked in the dummy app, is that it shares Gemfile with the engine.