0

I have a few rails apps that I have on a single VPS. I am using nginx, passenger, mysql and rails 4 for all of them. Two of the apps are working fine in the production ENV, but one of my apps is not switching to production. It just stays in development. I use mina for deployment. I've been pulling my hair out over this trying to figure out the reason why.

In my /etc/nginx/nginx.conf I have

 passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.in$
 passenger_ruby /home/ME/.rbenv/shims/ruby;
 passenger_app_env production;

and my server blocks for each of my apps are identical like this (replacing "mysite" with the respective app names)

server {
    listen 80;
   # listen [::]:80 ipv6only=on;

    server_name mysite.com www.mysite.com;
    passenger_enabled on;
    passenger_friendly_error_pages on;
    rails_env    production;
    root         /var/www/mysite.com/current/public;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

Can anyone help? I don't think Ive changed anything in the apps code, but can anyone think of something that I may have altered? Are there any rails files I could have changed that would be causing this? Thanks.

Update 7/13/14 So i've completely removed the files from my app on the server and re deployed fresh, and Im still having the problem. I am using mina to deploy my apps, and I ran mina deploy --trace and it says its doing $ RAILS_ENV="production" bundle exec rake assets:precompile RAILS_GROUPS=assets. I also added a test to my footer (Rails.env.production?) and it is returning false. Thanks for any help.

Update 7/14/14 So to test if it was my server or my code, I ran rails server -e production on my development machine. I still have the same problem with the Rails.env.production? returning false. So its clearly something in my rails code. Ihave no clue what I could have altered though still.

oobie11
  • 723
  • 1
  • 8
  • 20
  • Have you restarted nginx since making changes to the app? What makes you think your app isn't running in the production environment? – Alex P Jul 12 '14 at 12:58
  • Hi, thanks. I have restarted nginx. I know its not in production because I have a debug line in my footer that only shows up if `RAILS_ENV == 'development'`, and it still is showing when I visit it on my server. I have the same line in all of my apps, and its is preforming correctly in them, so its something with this app. – oobie11 Jul 13 '14 at 16:08

1 Answers1

0

So stupid me, i figured it out. I should have posted the code I had in my footer

<%= debug(params) if Rails.env = "development" %>
<%= sanitize("<b>Ruby</b>: #{RUBY_VERSION} <b>Rails:</b> #{Rails.version}") if Rails.env == "development" %>
<%= Rails.env.production? %>

The problem clearly was that I was assigning Rails.env to "development" instead of checking if IT WAS equal with "==". I changed that and now all is good.

oobie11
  • 723
  • 1
  • 8
  • 20