What’s the best way to configure variables in a JRuby application that’s deployed as a WAR file? The operations group will need to configure database settings and other environment variables depending on where my app is deployed. Since it’s a WAR file though they don’t have direct access to the database.yml or any of the environment files.
I want to be able to variablize anything they need to configure and have them perhaps put something into the Tomcat app.config/web.config. Is this possible to do? How do you bring those values into JRuby?
So to get parameters from the Tomcat servlet context in JRuby is very simple I discovered:
So for example if I had the following defined in the web.xml:
You can access the value in JRuby as follows:
This would return the string “jdbc:h2:localhost/~/test_db”.