2

本番環境をプリコンパイルすると、初期化されていない定数 ActionController::Caching::Sweeperエラーが発生します (heroku と同じ)。開発環境と localhost では、すべて正常に動作しています。任意の提案のための Thx。

C:\Sites\code\myapp>bundle exec rake assets:precompile RAILS_ENV=production --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant ActionController::Caching::Sweeper
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/spree_reviews-5447d2231446/app/models/spree/review_sweeper.rb:1:in `<top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
C:in `eager_load!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:150:in `block in tsort_each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_component_from'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_connected_component'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:180:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_component'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
C:/Sites/code/farmfood/config/environment.rb:5:in `<top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => environment
4

4 に答える 4

2

これはgemのバグrails-observersによるものです。バグは修正されましたが、修正はまだruby​​gems.orgに届いていません。

の次の行を置き換えてrails-observersGitHubのバージョンを使用しますGemfile

gem 'rails-observers'

これで:

gem 'rails-observers', git: 'https://github.com/rails/rails-observers.git'
于 2014-08-05T21:10:54.763 に答える
1

これは のバグですrails-observershttps://github.com/rails/rails-observers/issues/4

于 2013-10-16T11:37:11.200 に答える
0

これは、spree_reviews 拡張機能が、Rails 4 で削除された Rails の機能に依存しているためです。この問題については、そのプロジェクトで問題を報告してください。

于 2013-10-20T05:11:17.983 に答える
0

Thx @khustochka、私を正しい軌道に乗せてくれました

私は私の問題を解決しました:

gem のインストール'rails-observers' https://github.com/rails/rails-observers

次に、 production.rb に追加しました

  config.dependency_loading = true if $rails_rake_task
  config.active_record.observers = :contact_observer

初期化されていない定数 ActiveModel::Observer エラーが発生したため

app/models にファイル contact_observe.rb を作成しました

 class ContactObserver < ActiveRecord::Observer
   observe :user
 end

私がした後rake db:migrate RAILS_ENV=productionrake asset precompile RAILS_ENV=production

そして私の問題は修正されました

于 2013-10-16T22:20:07.350 に答える