I have an JRuby on Rails 3.1.6 application and want to deploy it on a Tomcat 7 as WAR file. To generate the war I use warbler.
I can deploy the application to the server and all is running. But the links generated or a redirect form devise to /users/sign_in dont work because the context path is ignored.
I tried to set the relative url root with:
config.action_controller.relative_url_root = '/foo'
But the method was not found. (Also tried the ENV variable for this, but nothing happened)
I tried to use scope '/foo' in my routes.rb but this doesn’t work either.
I also tried to add this in my config.ru
map '/foo' do
run Foo::Application
end
But the config.ru files seams not to be included in the WAR file or used in any way.
I can’t generate a VirtualHost or anything in tomcat, I have only the rights to deploy the application as WAR file. Is there any way to tell the rails application that it runs under a given subdirectory (context path) so it adds this to all generated links, redirects, etc., that works within Rails 3.1.6?
Sounds like a Devise thing, have you checked how it’s issuing the redirect ?
It should have worked, assuming you do something like the following from an action :
jruby-rack (gets included when you
warble) correctly handles cases when an application is running within a servlet context path different than /. I suggest to reverse the “hacks” you did trying to make things work and look into the code that redirected you … e.g. code such asredirect_to "/home/goodbye"won’t “work” (prefix the context path) as its assumed to be a complete URL path.As for the
config.rufor a Rails application Warbler does not copy it – thus it can distinguish a Rails from a plain Rack application (as jruby-rack does more hooks into Rails to provide a seamless experience with servlet containers such as Tomcat).