0
我試圖與MySQL數據庫conncet並獲得從該特定數據庫中的數據,但它正在崛起的錯誤..,修復它PLZ寶石2.0。與ActiveRecord的兼容性問題4.1.2
代碼是:
require 'rubygems'
#require 'mysql'
require 'active_record'
ActiveRecord::Base.establish_connection(
{
:adapter => 'mysql',
:host => 'localhost',
:database => 'spyware',
:user => 'root',
:password => 'sqlpass'
}
)
class Definition<ActiveRecord::Base
end
defni = Definition.Find(:all)
defni.each do |row|
print "\n\n".row.name
end
我得到的錯誤是::
ruby dbconnect.rb
C:/Ruby200/lib/ruby/gems/2.0.0/gems/activerecord-4.1.2/lib/active_record/connection_adapters/connection_specification.rb:190:in `rescue in spec': Specified 'mysql' for database adapter, but the gem is not loaded. Add `gem 'mysql'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activerecord-4.1.2/lib/active_record/connection_adapters/connection_specification.rb:187:in `spec'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activerecord-4.1.2/lib/active_record/connection_handling.rb:50:in `establish_connection'
from dbconnect.rb:6:in `<main>'
>Exit code: 1
我使用的2.0.14和MySQL版本的寶石版本2.8.1 86
已經添加,但它給 – 2015-03-31 12:11:55
你運行'捆綁安裝'來安裝gemfile中的所有寶石? – 2015-03-31 12:14:03
你能否清楚的解釋一下如何運行bundle install和els plz – 2015-04-02 05:53:18