4

Warbler wants you to specify a RAILS_ENV when creating the WAR. This is then put inside the web.xml of the generated WAR.

However, if you could create a wAR that learned its RAILS_ENV from the environment, you could create one WAR that could be used for staging or production - in other words, a superior management regime where a WAR can be tested and then deployed without being changed.

David W
  • 324
  • 1
  • 13

1 Answers1

3

JRuby-Rack is already set up to read from RAILS_ENV before what gets put in web.xml, so that part is golden. The only thing you need to defeat is this rails.erb template that gets merged into a META-INF/init.rb inside the war file:

ENV['RAILS_ENV'] = '<%= config.webxml.rails.env %>'

There isn't a real good way to do this at the moment, but you can override the Warbler::Jar#add_init_file as follows at the top of your config/warble.rb to remove the Rails template:

class Warbler::Jar
  alias_method :orig_add_init_file, :add_init_file
  def add_init_file(config)
    config.init_contents.delete("#{config.warbler_templates}/rails.erb") if config.init_contents
    orig_add_init_file(config)
  end
end
Nick Sieger
  • 3,315
  • 20
  • 14
  • Thank you! BTW, what is purpose of the Rails template (rails.erb) in META-INF/init.rb? Will there be any adverse effect from removing it? – David W Nov 27 '11 at 20:45