Ruby on Rails独角兽抛出错误

时间:2014-02-08 18:49:18

标签: ruby-on-rails ruby nginx unicorn

我在digitalocean上使用Ruby on Rails设置了一个Droplet,我删除了rails目录(App)并将其替换为我本地的目录。它工作正常,如果我连接到ssh并使用端口3000转到IP。但是每当我尝试转到端口80时,它会抛出一个错误: http://prntscr.com/2qoljb

我检查了日志,并说出以下内容:

Rails Error: Unable to access log file. Please ensure that /home/rails/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
Rails Error: Unable to access log file. Please ensure that /home/rails/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
I, [2014-02-08T18:40:59.192086 #735]  INFO -- : worker=1 ready
I, [2014-02-08T18:40:59.198211 #731]  INFO -- : worker=0 ready
Started GET "/" for 188.193.201.119 at 2014-02-08 18:41:00 +0000
Processing by QuestionsController#index as HTML
Completed 500 Internal Server Error in 43ms

ActiveRecord::StatementInvalid (Could not find table 'users'):
  app/controllers/application_controller.rb:18:in `current_user'
  app/controllers/application_controller.rb:10:in `require_login'


Started GET "/" for 188.193.201.119 at 2014-02-08 18:41:01 +0000
Processing by QuestionsController#index as HTML
Completed 500 Internal Server Error in 47ms

ActiveRecord::StatementInvalid (Could not find table 'users'):
  app/controllers/application_controller.rb:18:in `current_user'
  app/controllers/application_controller.rb:10:in `require_login'


Started GET "/" for 188.193.201.119 at 2014-02-08 18:41:02 +0000
Processing by QuestionsController#index as HTML
Completed 500 Internal Server Error in 2ms

ActiveRecord::StatementInvalid (Could not find table 'users'):
  app/controllers/application_controller.rb:18:in `current_user'
  app/controllers/application_controller.rb:10:in `require_login'


Started GET "/" for 188.193.201.119 at 2014-02-08 18:41:02 +0000
Processing by QuestionsController#index as HTML
Completed 500 Internal Server Error in 2ms

ActiveRecord::StatementInvalid (Could not find table 'users'):
  app/controllers/application_controller.rb:18:in `current_user'
  app/controllers/application_controller.rb:10:in `require_login'

表格应该存在,因为一切都工作得很好,如果我用端口3000手动输入IP ...

感谢您的提前帮助

修改 设置权限和所有者后,我收到以下错误:

/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/rails in PATH, mode 040777
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/rails in PATH, mode 040777
I, [2014-02-08T19:27:30.231141 #1984]  INFO -- : worker=1 ready
I, [2014-02-08T19:27:30.292714 #1981]  INFO -- : worker=0 ready

2 个答案:

答案 0 :(得分:1)

前两行明确说明了错误的文件权限,但Unicorn进程应该在与创建的日志文件相同的用户下运行。我猜capistrano和Unicorn在不同的用户下运行。

如果您不确定用户应该是什么,并且您没有安全问题,请运行:

$ chmod 0666 /home/rails/log/production.log

重新启动Unicorn之后,问题就会消失。

答案 1 :(得分:0)

我现在不关心日志文件的问题。我认为这不是根本原因。

引起我注意的是Could not find table 'users'。该应用程序在数据库中找不到表users或根本找不到数据库。是否在config/database.yml中检查了您对生产数据库的凭据?您是否在数据库上运行迁移?也许连接到生产数据库并检查模式是否与您期望的一样。