Ruby On Rails数据库连接

时间:2015-06-18 02:21:58

标签: ruby-on-rails

我正在学习RoR并且正在尝试建立一个数据库来连接。我认为这个问题与文件路径有关。当我输入" rake db:schema:dump --trace"我明白了:

rake aborted!
LoadError: cannot load such file -- bundler/setup
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/cannoncollins/Sites/simple_cms/config/boot.rb:3:in `<top (required)>'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/cannoncollins/Sites/simple_cms/config/application.rb:1:in `<top (required)>'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/cannoncollins/Sites/simple_cms/Rakefile:4:in `<top (required)>'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/cannoncollins/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/cannoncollins/.rbenv/versions/2.2.1/bin/rake:33:in `<main>'

这是我的database.yml:

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: ****
  password: ****
  host: localhost

development:
  <<: *default
  database: simple_cms_development

宝石清单:

*** LOCAL GEMS ***

bigdecimal (1.2.6)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
mysql2 (0.3.18)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
test-unit (3.0.8)

感谢任何帮助,谢谢

2 个答案:

答案 0 :(得分:0)

  耙子流产了! LoadError:无法加载此类文件 - bundler / setup

此问题的典型原因是您没有安装捆绑程序。尝试安装bundler,然后再次运行rake命令。

gem install bundler
bundle install
rake db:schema:dump --trace

希望这有帮助!

答案 1 :(得分:0)

在database.yml文件中,按如下方式添加socket -

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: ****
  password: ****
  host: localhost
  socket: /tmp/mysql.sock