need help deploying rails engine

I’m having problems deploying a rails application that contains engines.

When I had namespaced routes (Engine::Application.routes.draw) in routes.rb, I was unable to get past the “no such
file or directory” errors from apache. The request never got back to the application.

When I used global routes (Rails.application.routes.draw) in routes.rb, I can not direct the request to the namespaced controller. I get “uninitialized constant” with the non-namespaced controller name.

The Getting Started with Engines Rails Guide does not include information on deploying an application containing engines.

The relevant portion of the apache configuration is:

<Directory /var/www/html/links>
Options -MultiViews
RailsBaseURI /links
RailsEnv staging
PassengerRuby /usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby

/var/www/html/links is a symbolic link to the public directory of the deployed application.

A solution to either problem (namespaced or non-namespaced) is acceptable. A solution with namespaced routes is preferred.

Problem solved.

The namespaced paths generated by engine.path need to be modified by prefixing them with the applications base path. I use the apache RewriteRule for this:

RewriteRule ^/engine/?(.*) /app/engine/$1 [R]