Making ActionWebService work with Edge Rails
May 31st, 2007 by phil
I have a Rails application with a small SOAP service that is used for integration. Today I updated the site to Edge Rails and noticed a ton of strange errors related to ActionWebService. The first error looked like this:
Expected app/controllers/my_controller.rb to define MyController
I remembered hearing that ActionWebService was going to be moved out of Rails core, and I eventually found changeset 6550 from about 1 month ago where AWS was removed from the default load path. The ChangeLog suggests adding vendor/rails/actionwebservice/lib to config.load_paths. It turns out this is not enough. The app/apis directory also needs to be added to the load path and ‘action_web_service’ needs to be required.
Here is an excerpt from my environment.rb after making these changes:
Rails::Initializer.run do |config|
# Add additional load paths for your own custom dirs
config.load_paths += %W(
#{RAILS_ROOT}/app/apis
#{RAILS_ROOT}/vendor/rails/actionwebservice/lib
)
# ...more stuff...
end
require 'action_web_service'
This will get AWS working again, but functional tests may fail with the following error:
NoMethodError: undefined method 'invoke' for #<MyApiTest:0x3180f08>
There is one more change that is necessary: add require 'action_web_service/test_invoke' to the top of test/test_helper.rb.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'action_web_service/test_invoke'




