Search code examples
ruby-on-railsruby-on-rails-4nginxproduction-environment

Rails production server not showing changes to views


I'm hosting a Rails 4 app on an ec2 instance and using Nginx, I added a view to a controller and was getting an error trying to navigate to the page through my browser till I reloaded nginx.conf. Once it came up I made some changes to the view but those weren't showing either till I reloaded nginx.conf again.

Obviously I don't want to reload nginx.conf every time I need to change a view. Is there something I'm missing to make this easier on myself?

Here is my nginx.conf file.

server {
    listen       80;
    server_name  app-on-rails;
    passenger_enabled on;
    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    root   /home/usr/www/app-on-rails/welcome;
    index index.html.erb;
}

My environments/production.rb file

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_files = false
  config.assets.js_compressor = :uglifier
  config.assets.compile = true

Solution

  • Your nginx config appears to be using passenger. By default, in production mode all file content is parsed once, and cached in memory - so changes will not be immediately noticeable. To force a refresh, you need to at a minimum restart passenger. This can be done by simply touching the tmp/restart.txt file in your application root directory.