我的應用程序在生產中非常完美 - 至少是其網站的一部分。只有當我進入我的VPS並執行「rails c RAILS_ENV = production」時,纔會彈出問題。控制檯在開發模式下工作正常。無法打開rails控制檯:生產數據庫未配置,establish_connection引發ActiveRecord :: AdapterNotSpecified
我以前有過這個問題(或者至少有一個看起來像這樣),並且通過向database.yml添加「reconnect:true」來修復它 - 但這次沒有修復它。下面是錯誤輸出的開始:
/home/tour/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': RAILS_ENV=production database is not configured (ActiveRecord::AdapterNotSpecified)
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/railtie.rb:59:in `block (2 levels) in <class:Railtie>'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/railtie.rb:57:in `block in <class:Railtie>'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `instance_exec'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `run'
from /home/tour/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:50:in `block in run_initializers'
而對於我的生產數據庫設置:
production:
adapter: mysql
encoding: utf8
database: tour_production
pool: 5
username: [user]
password: [password]
socket: /var/run/mysqld/mysqld.sock
reconnect: true
我不能讓我的周圍爲什麼它的工作原理,通過乘客的心意,但與控制檯沒有運氣。無論如何,我使用Rails 3,Ruby 1.9.2,Passenger和Nginx。
我一直在做一些小東西,通過亞軍,這是煩人的。我想弄清楚這個問題。所以謝謝一幫人的幫助。
嗯,這樣做。看起來每個命令都有不同的方式來聲明rails環境。感謝大家的快速回答。 – Nathan 2010-09-06 21:08:13