2012-01-16 82 views
0

我想使用rails和spree gem(http://spreecommerce.com/)創建一個在線商店。安裝Spree ActiveRecord :: ConnectionNotEstablished錯誤

在我的Mac(os x lion)上留下了一段時間的rails開發,我使用本指南從零開始安裝了所有東西:http://tecparatodos.com/2011/07/24/installing-ruby-on-rails-on-mac-os-x-lion/和mysql與brew。

我也跟着狂歡的「入門文檔」 http://guides.spreecommerce.com/getting_started.html

所發生的問題是使用MySQL,配置數據庫和例如後做一個

rake db:create 

我總是得到ActiveRecord :: ConnectionNotEstablished錯誤。首先,我認爲它與我的MySQL安裝有關,但經過幾個小時的檢查和重新安裝後,我發現它實際上是因爲狂熱的寶石。每當我將「gem'spree'」添加到我的Gemfile中時,就會發生此錯誤。當我刪除它並執行「捆綁安裝」時,一切正常。我有一些觀看項目的鐵軌體驗,但狂歡對我來說是新的。任何想法可能是什麼問題?

我的database.yml:

development: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: asiashop_development 
    pool: 5 
    username: root 
    password: 
    socket: /tmp/mysql.sock 

# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: asiashop_test 
    pool: 5 
    username: root 
    password: 
    socket: /tmp/mysql.sock 

production: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: asiashop_production 
    pool: 5 
    username: root 
    password: 
    socket: /tmp/mysql.sock 

當我做stracktrace 「導軌C」:

/Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/model_schema.rb:224:in `columns' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/model_schema.rb:244:in `column_names' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/rd_searchlogic-3.0.1/lib/searchlogic/named_scopes/ordering.rb:61:in `ordering_condition_details' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/rd_searchlogic-3.0.1/lib/searchlogic/named_scopes/ordering.rb:52:in `method_missing' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.40.0/lib/spree_core/find_by_param.rb:105:in `<class:Base>' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.40.0/lib/spree_core/find_by_param.rb:104:in `<top (required)>' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:251:in `block in require' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:236:in `load_dependency' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.40.0/lib/spree_core.rb:47:in `<top (required)>' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree-0.40.0/lib/spree.rb:1:in `require' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree-0.40.0/lib/spree.rb:1:in `<top (required)>' 
    from /Users/mark/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' 
    from /Users/mark/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
    from /Users/mark/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each' 
    from /Users/mark/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require' 
    from /Users/mark/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each' 
    from /Users/mark/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require' 
    from /Users/mark/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler.rb:122:in `require' 
    from /Users/mark/Documents/Workspace/Asia Testshop/asiashop/config/application.rb:7:in `<top (required)>' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:39:in `require' 
    from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:39:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

正如我寫的,它不能是一般的MySQL conenction問題,因爲一切正常罰款只要我不使用狂歡寶石。

+0

您是否能夠爲此問題提供更大的堆棧跟蹤?你是如何配置你的'config/database.yml'的?你必須做了一些不同的事情,因爲Rails應用程序默認帶有sqlite3。 –

+0

我使用的是沒有問題的mysql,只要我不使用狂熱寶石。我在上面添加了stracktrace和我的database.yml。謝謝! –

回答

5

您需要的寶石施普雷添加到您的Gemfile這樣:

gem 'spree', '0.70.3' 

這將安裝最新的穩定版Spree。問題似乎是Bundler正在挑選Spree的一個非常舊的版本(0.40.0)來運行,這顯然是錯誤的。

+0

默認不安裝最新版本的gem嗎? – Lavixu

+1

@Lavixu如果其他寶石的寶石依賴規格要求最新以外的其他寶貝,做'gem'spree''只是意味着「我想要任何版本的Spree」 –

0

真的不能查明問題的,但卸載所有寶石,然後從從頭開始重新安裝後,他們的來源,我得到它的工作..

相關問題