简体   繁体   English

生产环境中的Rails供应商插件故障

[英]Rails vendor plugin failure in production environment

I expect this to be a n00b problem. 我希望这是一个n00b问题。

I'm attempting to use heroku with my rails app. 我正在尝试在我的Rails应用程序中使用heroku。 Everything works fine in development (local machine), but when I push to heroku I get the following: 在开发(本地计算机)中一切正常,但是当我推送到heroku时,得到以下信息:

==> dyno-1931938.log (crash) <==
/home/slugs/258915_4fd8878_0dbe-1413ed77-735c-469d-924e-619b28cdcbac/mnt/.bundle/gems/ruby/1.8/gems/activerecord-3.0.0/lib/active_record/base.rb:1016:in `method_missing': undefined local variable or method `acts_as_paranoid' for #<Class:0x2b469869b658> (NameError)
    from /disk1/home/slugs/258915_4fd8878_0dbe-1413ed77-735c-469d-924e-619b28cdcbac/mnt/app/models/my_model.rb:17

lines 16 and 17 of my_model.rb are: my_model.rb第16行和第17 my_model.rb是:

class Contact < ActiveRecord::Base
  acts_as_paranoid

'acts_as_paranoid' is a vendor plugin that was installed locally via: 'acts_as_paranoid'是一个通过以下方式在本地安装的供应商插件:

$git clone https://github.com/goncalossilva/rails3_acts_as_paranoid.git

What am I doing wrong that heroku is ignoring the plugin? heroku忽略了插件我做错了什么?


UPDATE: I cloned the repo from heroku, and the directory for the plugin exists, but is empty. 更新:我从heroku克隆了仓库,并且该插件的目录存在,但为空。 My other plugins (ie ssl_requirement) have the expect lib/ and init.rb. 我的其他插件(即ssl_requirement)具有期望的lib /和init.rb。 Obviously the code needs to be there to work. 显然,代码需要在那里工作。 What now? 现在怎么办?

Cloning the source retrieves the code from github, but it doesn't install the gem into your app. 克隆源可从github检索代码,但不会将gem安装到您的应用中。 Normally you'd install the gem on your local machine like this: 通常你会在本地机器上安装gem,如下所示:

gem install acts_as_paranoid

or 要么

sudo gem install acts_as_paranoid

Then tell Heroku about the gem by adding this to your .gems file: 然后通过将此添加到.gems文件中告诉Heroku有关gem的信息:

acts_as_paranoid

or better yet, specify the version that you expect, too (otherwise Heroku will grab the latest every time you push up new code to your app, which could cause unexpected breakage): 或者更好的是,也指定您期望的版本(否则,每次将新代码推送到应用程序时,Heroku都会获取最新版本,这可能会导致意外损坏):

acts_as_paranoid --version x.y.z

And make sure your config/environment.rb has an entry for the gem so its absence will be detected at launch instead of later: 并确保您的config / environment.rb中有一个gem条目,以便在启动时(而不是以后)检测到它的缺失:

config.gem 'acts_as_paranoid', :version => 'x.y.z'

PS: All of the above will be somewhat different if you're using Rails 3 and/or Bundler to manage your gems. PS:如果您使用Rails 3和/或Bundler管理您的宝石,上述所有内容都会有所不同。

It turns out vendor/plugins/my_plugin_directory had fallen out of the git tree. 事实证明, vendor/plugins/my_plugin_directory已经脱离了git树。 I resolved the problem by: 我解决了这个问题:

$cd rails_root_directory
$git fsck
$git rm --cached vendor/plugins/my_plugin_directory
$git add vendor/plugins/my_plugin_directory/*
$git commit -am "my_plugin added to repository"
$git push heroku master

and all is right now. 现在一切都正常了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM