2010-12-17 74 views
1

我知道這已經被不同的其他用戶用類似的問題問了很多次,但我不能似乎找到了一個類似於我的情況:MySql2在Mac OS X的Rails 3.0.3

我規格:

OS - Mac OSX 10.6 Snowleopard 
SQL Server - MySQL 5.5 
Rails - 3.0.3 
Ruby 1.8.7 

雖然嘗試運行耙分貝:創建,我遇到了以下錯誤消息:

"uninitialized constant Mysql2" 
如果你有興趣

完整跟蹤過帳: -

** Invoke db:create (first_time) 
** Invoke db:load_config (first_time) 
** Invoke rails_env (first_time) 
** Execute rails_env 
** Execute db:load_config 
** Execute db:create 
rake aborted! 
uninitialized constant Mysql2 
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:64:in `create_database' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:33 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 
/usr/bin/rake:19:in `load' 
/usr/bin/rake:19 

回答

0

嘗試:

sudo gem install mysql2 
bundle install 
+0

我嘗試了很多次,但仍然無法正常工作。 – cherhan 2010-12-18 00:08:25

+0

也沒有在這裏工作。 – gokujou 2011-03-14 21:30:05

4

同樣的配置,在這裏同樣的問題...

編輯:解決了!必須將gem 'mysql2'添加到Gemfile並運行軟件包安裝。現在它工作正常。

+0

這一個工程。 – gokujou 2011-03-14 21:35:03