Rails Console vs. Server Differences on a Production Server

By deploying a very simple Rails 3.2.3 test site to a "production" server (actually not in production, fortunately!) With RVM Ruby 1.9.3-p194, I believe the following: here:

╔══════════════════════════════════════╀═══╗ β•‘ command issued β”‚OK?β•‘ β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β•’ β•‘ bundle exec rails console β”‚ N β•‘ β•‘ bundle exec rails console production β”‚ Y β•‘ β•‘ bundle exec rails server β”‚ Y β•‘ β•‘ bundle exec rails server production β”‚ N β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β• 

My first question is: was this expected? (I would think that the template in the right column should be NYNY.)

Additional information: bundle exec rails console not suitable for the obvious reason that the sqlite3 stone is not installed on the server. However, bundle exec rails server production fails with much less clear tracing:

 $ bundle exec rails server production Exiting /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:63:in `require': cannot load such file -- rack/handler/production (LoadError) from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:63:in `try_require' from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:16:in `get' from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:269:in `server' from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:59:in `start' from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>' from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap' from /home/spkspike/www/spike.sampablokuper.com/releases/20120530134819/vendor/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' 

My second question is: what is the best way to fix this error?

+7
source share
2 answers

Would you like to start the server in production mode using the working environment?

 rails server -e production 

The syntax difference between the rails console environment and the server -e rails environment is a bit of PITA

+18
source

In case the console production defines the environment, and in the case of the server - something else (it is possible which server to use webrick / ...).

So, if you want to specify the environment:

 ENV=production rails server 
+3
source

All Articles