Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails assumes too much about the name of the "production" environment

#6751

For various reasons, we actually have several "production" Rails environments, and have a naming convention for them along the lines of "prod1", "prod2", etc. We've found that within the Rails source, there are a few checks for Rails.env.production?, which assumes the name of your production Rails environment is always just "production". For example:

https://github.com/rails/rails/blob/master/railties/lib/rails/appli...
https://github.com/rails/rails/blob/master/railties/lib/rails/appli...
https://github.com/rails/rails/blob/master/railties/lib/rails/test_...

This has tripped us up a couple of times. It would be nice if Rails provided a hook that allowed you to override the default name of the production environment, and also accounts for the fact that there could be more than one environment that are "production" like.

I understand that this is breaking a very well understood Rails convention, but as more and more SaaS apps are built with Rails (as ours is) this is becoming prohibitive.

Thoughts?

Reported by Brian Ploetz · April 26th, 2011 @ 09:50 PM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Pavel Lazureykis
    Pavel Lazureykis

    Can you override this method?

    config/initializers/00_production_environments.rb

    module ActiveSupport
    class StringInquirer < String

    def production?
      %w(production prod1 prod2).include? self
    end
    

    end end

    May 18th, 2011 @ 09:16 PM

  2. Steven Soroka
    Steven Soroka
    • Tag changed from environments, production to environments, invalid, production

    For such a special case, just override what production means like Pavel suggested.

    -1

    May 20th, 2011 @ 03:50 AM

  3. Brian Ploetz
    Brian Ploetz

    Yes, of course we can just monkey patch ActiveSupport::StringInquirer.production? like that. That just seems a little brittle to me. My larger point was that as more and more SaaS apps get built with Rails, this may not be such a special case.

    May 20th, 2011 @ 04:43 PM