Question

We have a Rails application built with JRuby, and deployed to JBoss as a war file generated by warbler.

In our views, we have link_to calls like so:

<%= link_to "link", "path/to/file" %>

However, we have set our context-root in jboss-web.xml to something like:

<context-root>my/app</context-root>

The end result is that after deploying our war file to JBoss, the links above are broken since they do not include the prefix as specified by the context-root value.

Is there any way for me to obtain the value of this context-root from JRuby/Rails so that I can fix my links?

Was it helpful?

Solution

jruby-rack exposes the context-root as the environment variable ENV['RAILS_RELATIVE_URL_ROOT']. You can find details in the setup_relative_url_root method in jruby-rack.

Using this, I was able to make corrections to the paths that were previously borked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top