Rails vendor plugin failure in production environment
I expect this to be a n00b problem.
I'm attempting to use heroku with my rails app. Everything works fine in development (local machine), but when I push to heroku I get the following:
==> 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:
class Contact < ActiveRecord::Base
acts_as_paranoid
'acts_as_paranoid' is a vendor plugin that was installed locally via:
$git clone https://github.com/goncalossilva/rails3_acts_as_paranoid.git
What am I doing wrong that heroku is ignoring the plu开发者_Python百科gin?
UPDATE: I cloned the repo from heroku, and the directory for the plugin exists, but is empty. My other plugins (i.e. ssl_requirement) have the expect lib/ and 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. Normally you'd install the gem on your local machine like this:
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:
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):
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.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.
It turns out vendor/plugins/my_plugin_directory
had fallen out of the git tree. 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.
精彩评论