This project is archived and is in readonly mode.

#6751 new
Brian Ploetz

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

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

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:

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.


Comments and changes to this ticket

  • Pavel Lazureykis

    Pavel Lazureykis May 18th, 2011 @ 09:16 PM

    Can you override this method?


    module ActiveSupport
    class StringInquirer < String

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

    end end

  • Steven Soroka

    Steven Soroka May 20th, 2011 @ 03:50 AM

    • Tag changed from environments, production to environments, invalid, production

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


  • Brian Ploetz

    Brian Ploetz May 20th, 2011 @ 04:43 PM

    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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket