Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 - development errors in production mode
    primarykey
    data
    text
    <p>Im using Rails, Passenger (both are 3.0.5) and Nginx on my production server. As I heard, Rails should show <code>public/404.html</code> or <code>public/500.html</code> instead of development errors like <code>ActiveRecord::RecordNotFound</code> or <code>Unknown action</code> but that doesn't happen. I've tried to delete config.ru file and set rack_env or rails_env in nginx.conf but nothing helped.</p> <p>Here is my nginx.conf:</p> <pre><code>worker_processes 1; events { worker_connections 1024; } http { passenger_root /home/makk/.rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.5; passenger_ruby /home/makk/.rvm/bin/passenger_ruby; #passenger_ruby /home/makk/.rvm/wrappers/ruby-1.9.2-p0/ruby; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /home/makk/projects/1server/deploy/current/public; index index.html index.htm; passenger_enabled on; rack_env production; recursive_error_pages on; if (-f /home/makk/projects/1server/maintenance.html) { return 503; } error_page 404 /404.html; error_page 500 502 504 /500.html; error_page 503 @503; } location @503 { error_page 405 = /maintenance.html; # Serve static assets if found. if (-f $request_filename) { break; } rewrite ^(.*)$ /maintenance.html break; } location ~ ^(\/phpmyadmin\/)(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(\/phpmyadmin\/)(.*)$; fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin/$fastcgi_path_info; include fastcgi_params; } } } </code></pre> <p>It seems that this question duplicates <a href="https://stackoverflow.com/questions/4330093/getting-development-errors-in-production-mode">this one</a> but there are no working suggestions.</p> <p><strong>UPD</strong>: I have both development and production apps on same PC. In production Rails ignores <code>config.consider_all_requests_local = false</code> (in /config/environments/production.rb) due to <code>local_request?</code> method. So one of possible solutions is listed below (taken from <a href="http://www.neeraj.name/2009/02/05/rescue_action_in_public-local_request-and-how-to-configure-local_request.html" rel="nofollow noreferrer">here</a>):</p> <pre><code># config/initializers/local_request_override.rb module CustomRescue def local_request? return false if Rails.env.production? || Rails.env.staging? super end end ActionController::Base.class_eval do include CustomRescue end </code></pre> <p>Or for Rails 3:</p> <pre><code>class ActionDispatch::Request def local? false end end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload