I am using MySQL and ruby 1.8.6. I want to connect to MySQL so for that I am using active record gem. My code is
def initialize
@db_adapter = "mysql2"
@db_host = "localhost"
@db_database = "database_name"
@db_user = "root"
@db_password = "root123"
con = nil
end
def database_connection
con = ActiveRecord::Base.establish_connection(
:adapter => $db_adapter,
:host => $db_host,
:database => $db_database,
:user => $db_user,
:password => $db_password
)
return con
end
but when i am tring to connect it's giving me this error
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in `establish_connection': Please install the adapter: `gem install activerecord--adapter` (no such file to load -- active_record/connection_adapters/_adapter) (RuntimeError)
from /cmf/samnew/build/Controller/databaseConnection.rb:32:in `database_connection'
from controller.rb:23