ruby-on-rails – 生产服务器上的Rails控制台与服务器差异

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 生产服务器上的Rails控制台与服务器差异前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
使用RVM Ruby 1.9.3-p194将一个非常基本的Rails 3.2.3试用站点部署到“生产”服务器(不是真的在生产中,谢天谢地!),我发现以下列出的命令如下:
╔══════════════════════════════════════╤═══╗
║ 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 ║
╚══════════════════════════════════════╧═══╝

我的第一个问题:这是预期的吗? (我原以为右列中的模式应该是N-Y-N-Y.)

更多信息:bundle exec rails console失败,原因是服务器上没有安装sqlite3 gem.但是,bundle exec rails服务器生产失败,而且跟踪的可理解程度要低得多:

$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>'

我的第二个问题:如何最好地解决错误

解决方法

您不想使用生产环境在生产模式下启动服务器吗?
rails server -e production

rails控制台环境和rails服务器-e环境之间的语法差异有点像PITA

原文链接:https://www.f2er.com/ruby/268666.html

猜你在找的Ruby相关文章