rake assets:precompile --trace
を実行したときに、アプリケーションがデータベースに接続しようとしている理由をデバッグしようとしています。
私はおそらくスタックトレースに何かが欠けています...誰かが関連する行を見ますか?
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in ActionController::Base instead. (called from <top (required)> at /Users/Kyle/Desktop/skateparks-web/config/application.rb:4)
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/bin/Ruby /Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/bin/rake assets:precompile:all Rails_ENV=production Rails_GROUPS=assets --trace
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in ActionController::Base instead. (called from <top (required)> at /Users/Kyle/Desktop/skateparks-web/config/application.rb:4)
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
FATAL: database "skateparks_production" does not exist
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `initialize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `new'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `connect'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:316:in `initialize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:27:in `new'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:27:in `postgresql_connection'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:277:in `new_connection'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:287:in `checkout_new_connection'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:235:in `block (2 levels) in checkout'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `loop'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `block in checkout'
/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/lib/Ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/model_schema.rb:308:in `clear_cache!'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activerecord-3.2.0/lib/active_record/railtie.rb:91:in `block (2 levels) in <class:Railtie>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:418:in `_run__2041913228368879189__prepare__1991931652306887621__callbacks'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/actionpack-3.2.0/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/actionpack-3.2.0/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/application/finisher.rb:48:in `block in <module:Finisher>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/initializable.rb:30:in `instance_exec'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/initializable.rb:30:in `run'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/initializable.rb:55:in `block in run_initializers'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/initializable.rb:54:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/initializable.rb:54:in `run_initializers'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/application.rb:136:in `initialize!'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/railtie/configurable.rb:30:in `method_missing'
/Users/Kyle/Desktop/skateparks-web/config/environment.rb:5:in `<top (required)>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `block in require'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/application.rb:103:in `require_environment!'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/railties-3.2.0/lib/Rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/lib/Ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:89:in `block (2 levels) in <top (required)>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/lib/Ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/lib/Ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/lib/Ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/bin/rake:19:in `load'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/bin/rake:19:in `<main>'
Tasks: TOP => environment
rake aborted!
Command failed with status (1): [/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/bi...]
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:53:in `block in create_Shell_runner'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:45:in `call'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:45:in `sh'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `sh'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:78:in `Ruby'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `Ruby'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:9:in `Ruby_rake_task'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/Ruby-1.9.2-p290/lib/Ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/bin/rake:19:in `load'
/Users/Kyle/.rvm/gems/Ruby-1.9.2-p290@skateparks/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile
rake assets:precompile
デフォルトでアプリを初期化します。これには、データベースへの接続が含まれます。
内部config/application.rb
これを追加できますが、警告については以下のリンクを参照してください。
config.assets.initialize_on_precompile = false
状況に応じて、どの環境に対して選択するかを選択できますassets:precompile
は、次のコマンドで機能するはずです。
rake assets:precompile:all Rails_ENV=development Rails_GROUPS=assets
通常、これは私の展開にとって意味があります。
それが役に立てば幸い。
私も同じ問題を抱えていました。 Sprocketsをバージョン3に更新した後、アセットをローカルでプリコンパイル(開発)しようとしたが、本番環境の設定を使用すると、次のエラーが発生しました。
レーキが中止されました! Gem :: LoadError:データベースアダプタに「postgresql」を指定しましたが、gemがロードされていません。
gem 'pg'
をGemfileに追加します(そして、そのバージョンがActiveRecordに必要な最小値であることを確認します)。
ローカル(開発)ではMySQLを使用し、サーバー(本番)ではPostgresを使用しているためです。
config.assets.initialize_on_precompile
はRails 4.2.1
で使用できないため、解決済みとしてマークされた回答は機能しません。
解決するために、私は3つの簡単なステップに従いました。
gem "activerecord-nulldb-adapter"
database.yml
で、アダプターを次のように変更します。
production:
adapter: <%= ENV['DB_ADAPTER'] ||= 'postgresql' %>
プロダクションアセットをローカルでコンパイルします。ターミナルで実行する
DB_ADAPTER=nulldb Rails_ENV=production rake assets:precompile
この解決策は私に解決し、私は ここ を見ました。