NameError: ApplicationAPI


Just for the record…

I’ve seen occasional mentions of a problem people have had upgrading
existing Rails 1.1.x applications to Rails 1.2.x, leading to complete
failure of the application with the message:

NameError: Neither ApplicationApi or ApplicationAPI found

…but I’ve never seen a general solution posted, or even an explanation
of what caused it. (Google finds this:

but it appears not to have helped most people).

Yesterday I ran into the problem myself and thought I should post the
probable cause and likely fix for posterity.

The problem: The older application has web services enabled but is not
actually using / defining and web services (i.e., does not define the
class ApplicationAPI). This was not a problem in earlier versions of
Rails as the didn’t try to access the API if it wasn’t defined; later
versions apparently assume that if you are using web services you have
an API defined.

What is likely to fix it: find the line(s) in config/environments.rb
that disable unused frameworks and make sure that you are disabling

config.frameworks -= [:action_web_service, … ]

You may also need to check config/environments/*.rb as the settings
there would override those in environments.rb.