Setting RAILS_ENV from a jvm option?

I realize this is a Rails specific question - but it’s also specific to
jRuby, so I’m hoping someone can help me out as I haven’t found an
via google yet.

We run development, staging, preview and production servers for our java
apps. We use a jvm option on each of these servers to indicate which it

  • very much like RAILS_ENV is used - so that java apps can be configured
    act appropriately.

Not only would it be extremely helpful to be able to take advantage of
already set JVM options, but I’m stuck if I’m not able to… our
environment is setup such that once a .war file hits staging, that same,
unmodified version is the one that gets pushed up the ladder till it
prod. I can’t, therefore, re-package it with Warbler at each step -
changing the rails_env as we go. (Which is not something I’d consider a
good practice anyway…).

So… can someone shed some light on whether or not I can add something
the project to set RAILS_ENV from a jvm option when the app starts up?

[email protected]

We did this by overriding the RAILS_ENV based on an option set in the
jvm. I’m interested if there’s a better way. Looks like this:


in environment.rb

ENV[‘RAILS_ENV’] = ENV_JAVA[‘rails.env’]


On Fri, Oct 23, 2009 at 1:42 PM, [email protected] Hunter [email protected]

Not only would it be extremely helpful to be able to take advantage of these
[email protected]

“You can never run a hill too hard. You will give up long before you hurt
the hill…” -Anon

To unsubscribe from this list, please visit:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs