Hello every body, i have met a strange issue about activerecord gem.

This is my simple code:

===========================
#!/usr/bin/ruby
require "rubygems"
require "active_record"

ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:database => "database",
)

class Text < ActiveRecord::Base
end

Text.create(:title => 'hello')
===========================

When i execute it in home dir, it works well.

======
abc@abc-desktop:~$ pwd
/home/abc
abc@abc-desktop:~$ ruby/mysql.rb
/var/lib/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:619:in
`real_connect': Access denied for user 'root'@'localhost' (using
password: NO) (Mysql::Error)
======

And then i change the work dir, it returns "Load Error".

======
abc@abc-desktop:~/ruby$ pwd
/home/abc/ruby
abc@abc-desktop:~/ruby$ ./mysql.rb
/var/lib/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:7:in
`define_all_hashes_method!': Mysql not loaded (RuntimeError)
======

Who can tell me how this happend?

thanks

- grick

-- 
Posted via http://www.ruby-forum.com/.