2013-06-05 36 views
0

我是一個新手,Ruby on Rails和我下面的邁克爾·哈特爾的3.2教程的內容作爲參考。我讓我的應用程序運行並部署到Heroku上,直到我嘗試添加非官方的yummly gem。 http://rubygems.org/gems/yummly/versions/0.0.7導軌和Yummly寶石正常工作在本地,但未能在Heroku

我得到它的本地工作(品牌並獲取API罰款),但是當我把它推到Heroku上,應用程序崩潰,並說,它無法在第5行的輔助文件找到Yummly.rb。

除了包括

需要Yummly

在我的控制器類和

寶石 「yummly」

在我的Gemfile(和運行包安裝),有什麼事情我會丟失?也許我需要指定該寶石需要最新的版本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

require需要一個文件或寶石名要求所以它定義的類和模塊是在當前文件訪問。

因此,你應該做到以下幾點:

require 'yummly' 

注意一個事實,即它是一個字符串,而不是一個常量。 按照慣例,它也完全被降級,ruby中的文件名從不會取任何大寫字母。

但是,由於您使用的捆綁,你應該知道,是自動地管理需要你的依賴。因此,你根本不需要你的依賴。

+0

感謝您的信息。當我拿出要求時它仍然在本地工作。可悲的是,當我將它部署到Heroku時,它仍然無法解決問題。 – Alex

+1

其實這確實解決了它。我在另一個我忘記的幫手中有'要求Yummly'。非常感謝! – Alex

相關問題