How to tell if rails is in production?

后端 未结 6 1804
眼角桃花
眼角桃花 2020-12-23 11:20

I used script/server -e production to start rails in production mode. It did and I got no errors. However how do I tell if it is in production mode? I tried a n

6条回答
  •  盖世英雄少女心
    2020-12-23 11:28

    2 easy ways:

    tail -f log/production.log
    

    if there are entries populating that log after you hit the app, you're in production mode.

    second way:

    in one of your views (probably the layout is good), just add

    <%= "Environment: #{RAILS_ENV}" %>
    

    And that will show you what the environment that you're running in.

    edit

    You will see the default exception page instead of the actual error pages on any environment if the request is considered "local" (that is from localhost or 127.0.0.1), you can override this by adding this to your ApplicationController

    def local_request?
      false
    end
    

    You can find this method in the docs in the api

提交回复
热议问题