From: Rob Mauchel Date: 2009-11-15T22:16:05+09:00 Subject: Using activerecord with mysql Hi All, I've successfully been using Ruby on one machine for quite some time and now, on another machine, after: installing Ruby 1.86-27 rc2 (using the one click installer for Windows obtained from www.ruby-lang.org, with the 'Enable RubyGems' option checked) installing the additional gems activerecord and mysql (using gem install ...) installing mysql 5.1.40 (from mysql.com), using the typical install option running the mysql server instance configuration wizard, selecting 'standard configuration', 'install as windows service', 'launch the mysql server automatically', and not changing the root password copying libmysql.dll into c:\ruby\bin creating a new database 'test' (default charset and collation) with table 'a' containing integer field 'x' I find that the following Ruby code: require 'active_record' class User < ActiveRecord::Base establish_connection(:adapter => 'mysql', :host => 'localhost', :username => 'root', :password => '', :database => 'test') puts(connected?()) set_table_name('a') end user = User.new("x" => 5) user.save() generates 'false' for the return value from 'connected?()' and the following exception on user.save() that confirms the lack of a connection: Mysql::Error: query: not connected: INSERT INTO `a` (`x`) VALUES(5) (ActiveRecord::StatementInvalid) Note that there is definitely communication going on with the database server as changing any of the above parameters to establish_connection generates an exception, as expected, while the above parameters do not. Can anyone advise as to why activerecord is unable to successfully connect (not to mention why it doesn't generate an exception indicating why)? Any assistance would be greatly appreciated! -- Posted via http://www.ruby-forum.com/.