2

按照教程,我成功地在本地制作了一个简单的 RoR 应用程序(使用 SQLite 和一些非常简单的数据模型),并通过 git 与 heroku 同步。(Heroku 服务器启动并显示通常的欢迎页面。)

但是,如果我想访问我的班级网址之一,例如/users,我会收到以下消息:

内部服务器错误

nil:NilClass 的未定义方法“信息”

heroku logs揭示

ERROR NoMethodError: undefined method `info' for nil:NilClass
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/runtime.rb:17:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/rack/logger.rb:25:in `call_app'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/rack/logger.rb:16:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/applicatio
n.rb:220:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/methodoverride.rb:21:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/lock.rb:15:in `call'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/middleware/static.rb:62:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/content_length.rb:14:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/handler/webrick.rb:59:in `service'
/usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:479:in `call'
heroku[router]: at=info method=GET path=/users host=xxx.herokuapp.com fwd=178.190.207.99 dyno=web.1 queue=0 wait=0ms connect=0ms service=12ms status=500 bytes=340

它似乎与 request 中的部分有关at=info。到目前为止,我的研究似乎表明与ActiveRecord:Base.logger但我不明白它有联系。

我什至从哪里开始寻找原因?

在其他帖子中,Gemfile 也是相关的,所以这里是:

source 'https://rubygems.org'

gem 'rails', '3.2.7'

group :development do
    gem 'sqlite3', '1.3.7'
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
4

2 回答 2

1

运行以下命令(如果您还没有):

heroku run rake db:migrate

你的用户控制器是什么样的?

的输出是rake routes什么?

于 2013-01-13T16:39:09.503 回答
0

添加这个:

config.active_record.logger=Logger.new(STDOUT)

配置/环境/xxx.rb。xxx 是您正在使用的环境的名称,它应该是开发、生产或测试。

于 2017-06-30T05:28:46.487 回答