【问题标题】:Remote Heroku application crashes; local is fine远程 Heroku 应用程序崩溃;当地很好
【发布时间】:2013-04-15 22:39:32
【问题描述】:

我有一个可以在本地运行的 Rails 应用程序(使用 bundle exec 测试),但在 Heroku(Cedar 堆栈)上崩溃了。本地配置与远程配置相同(都使用 Postgres)。崩溃实际上让我很困惑,因为堆栈跟踪似乎发生在 Rails/Thin 环境中。弃用警告同样令人困惑,因为我的供应商/插件目录中没有任何内容!

Starting process with command `bundle exec thin start -R config.ru -e $RAILS_ENV -p 38427`
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/ and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/ and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation.rb:378:in `destroy': wrong number of arguments (0 for 1) (ArgumentError)
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /app/app/models/transcript.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:359:in `require_or_load'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/querying.rb:7:in `destroy'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /app/app/models/transcript.rb:4:in `<class:Transcript>'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from config.ru:1:in `new'
from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/controllers/controller.rb:181:in `load_rackup_config'
from config.ru:3:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/bin/thin:6:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/rack/adapter/loader.rb:33:in `load'
from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/controllers/controller.rb:71:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:313:in `depend_on'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436:in `eager_load!'
from /app/config/environment.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in `block in eager_load!'
from config.ru:3:in `block in <main>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'
from /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/rack/adapter/loader.rb:33:in `eval'
from config.ru:1:in `<main>'
Process exited with status 1
State changed from starting to crashed

我已经运行了rake db:resetrake db:migrate 只是为了确保它不是数据库系统的问题。

脚本文件的内容:

class Transcript < ActiveRecord::Base
  attr_accessible :grade, :hours

  belongs_to :student, class_name: 'User', dependent: destroy
  belongs_to :course
end

【问题讨论】:

  • 你的意思是heroku pg:reset DATABASE_URL
  • 请参阅stackoverflow.com/questions/9027403/… 了解弃用警告。
  • Transcripts 模型文件中有什么?
  • 它似乎在抱怨app/models/transcript.rb - 请同时发布文件的内容
  • @Tonys:已发布。看起来它不喜欢依赖:标志...奇数。

标签: ruby-on-rails ruby postgresql heroku


【解决方案1】:

您的模型应该如下所示。

class Transcript < ActiveRecord::Base
  attr_accessible :grade, :hours

  belongs_to :student, class_name: 'User', dependent: :destroy
  belongs_to :course
end

发生的情况是您没有将destroy 定义为字符串或散列。这就是为什么你得到...

`destroy': wrong number of arguments (0 for 1) (ArgumentError)

【讨论】:

  • 谢谢!那解决了它。任何想法为什么它在本地工作,但在远程却惊人地死亡?
  • 不确定。也许有更多知识的人可以启发我们。我很想知道为什么。
猜你喜欢
  • 2020-08-30
  • 1970-01-01
  • 2019-02-06
  • 2011-10-03
  • 2022-07-28
  • 2020-12-22
  • 2015-04-22
相关资源
最近更新 更多