【问题标题】:Errors when trying to create a mysql database for rails spree project尝试为 rails spree 项目创建 mysql 数据库时出错
【发布时间】:2012-06-05 21:27:29
【问题描述】:

当我尝试使用 mysql 数据库将 spree 安装到新的 rails 项目时出现以下错误。安装 spree 我得到以下错误,我不是 100% 如何解决它:

/Users/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-  3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.5/lib/active_record/model_schema.rb:228:in `columns'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.5/lib/active_record/model_schema.rb:248:in `column_names'
from /Users/.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/.rvm/gems/ruby-1.9.2-p290/gems/rd_searchlogic-3.0.1/lib/search logic/named_scopes/ordering.rb:52:in `method_missing'
from /Users/.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/.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/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in `require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in `require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.40.0/lib/spree_core.rb:47:in `<top (required)>'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/spree-0.40.0/lib/spree.rb:1:in `require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/spree-0.40.0/lib/spree.rb:1:in `<top (required)>'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `block in require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
from /Users/Downloads/blind-love/blind-love/config/application.rb:7:in `<top (required)>'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.5/lib/rails/commands.rb:24:in `require'
from /Users/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.5/lib/rails/commands.rb:24:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
    precompiling  assets
    rake aborted!
    ActiveRecord::ConnectionNotEstablished

我的数据库yaml文件如下:-

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


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

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

【问题讨论】:

    标签: mysql ruby-on-rails activerecord yaml


    【解决方案1】:

    在使用delayed_job时遇到了同样的问题,还没有找到解决方法。

    编辑:我的问题是当我尝试使用它时,我认为活动记录尚未完全设置。当我通过我需要运行到 application.rb 中的 config.after_initialize 的块时,问题就消失了。

    【讨论】:

    • 当我输入 gem install spree 时已经解决了发生的事情是安装了 spree 电子商务版本 0.4 而不是版本 1.0 ,所以在我的 gem 文件中我指定了版本 1.0 并且问题得到了解决。
    猜你喜欢
    • 2010-11-28
    • 2016-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    相关资源
    最近更新 更多