ruby-on-rails-使用Nginx的Rails的多阶段环境

我创建了新的环境“ staging”.在本地有效.我这样运行:RAILS_ENV=staging passenger start在服务器上,我使用Nginx passenger.在虚拟主机设置中,我写了:server {listen 443;server_name test.myapp.com;rail...

我创建了新的环境“ staging”.在本地有效.我这样运行:

RAILS_ENV=staging passenger start

在服务器上,我使用Nginx passenger.在虚拟主机设置中,我写了:

server {
        listen       443;
        server_name  test.myapp.com;
        rails_env staging;
        root /home/admin/myapp/current/public; # <-- be sure to point to 'public'
        passenger_enabled on;
        ssl on;
        ssl_certificate /home/admin/ssl/server.crt;
        ssl_certificate_key /home/admin/ssl/server.key;
}
server {
        listen 80;
        server_name  test.myapp.com;
       root /home/admin/myapp/current/public;  
        rewrite ^ https://$server_name$request_uri? permanent;
}

但是应用仍在生产中运行.它加载生产数据库,而不是暂存.重新加载Nginx没有帮助.怎么了?

解决方法:

我认为您缺少rails_env设置.

server {
  ...
  rails_env staging;
}

本文标题为:ruby-on-rails-使用Nginx的Rails的多阶段环境

基础教程推荐