带有Yummly Gem的Rails在本地工作正常,但在Heroku上失败了

时间:2013-06-05 12:15:18

标签: ruby-on-rails heroku

我是Ruby on Rails的新手,并且正在关注Michael Hartl的3.2教程书作为参考。我让我的应用程序运行并部署到Heroku上,直到我尝试添加非官方的yummly gem。 http://rubygems.org/gems/yummly/versions/0.0.7

我让它在本地工作(制作和获取api很好),但当我将它推送到Heroku时,应用程序崩溃并说它在第5行的帮助文件中找不到Yummly.rb。

除了包括

  

要求Yummly

在我的控制器类和

  

宝石“yummly”

在我的Gemfile中

(并运行bundle install),我可能会缺少什么?也许我需要指定gem需要是0.0.9的最新版本(我无法安装它所以我没有尝试更改它)?

这是否与Heroku有关?还是特意与Yummly Gem有关?

Heroku记录如下

State changed from crashed to starting
Starting process with command `bundle exec thin start -R config.ru -e $RAILS_ENV -p 51790`
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/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on': Missing helper file helpers/Yummly.rb (LoadError)
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/helpers.rb:92:in `modules_for_helpers'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:131:in `modules_for_helpers'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:131:in `map!'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:135:in `block in modules_for_helpers'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
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/actionpack-3.2.13/lib/abstract_controller/helpers.rb:159:in `default_helper_module!'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:135:in `inherited'
from /app/app/controllers/application_controller.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:95:in `helper'
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 `block in require'
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/actionpack-3.2.13/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in with'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:22:in `block in inherited'
rom /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:22:in `class_eval'
from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:22:in `inherited'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436:in `ea

1 个答案:

答案 0 :(得分:1)

require需要文件或gem名称,因此可以在当前文件中访问它定义的类和模块。

因此,您应该执行以下操作:

require 'yummly'

请注意,它是一个字符串而不是常量。 它也完全是低级的,按照惯例,ruby中的文件名永远不会取任何大写。

但是,由于您使用的是bundler,因此您应该知道自动管理需要您的依赖项。因此,您根本不需要依赖。