我在Mac OSX 10.6.4上运行ruby,使用Ruby 1.8和activerecord 2.3.8。我运行下面的代码的NetBeans 6.9的内部,但我使用的是Ruby解释器从10.6Ruby activerecord似乎忽略set_table_name
我有以下代码:
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection
(
:adapter=> "mysql",
:host => "localhost",
:username => "test",
)
class Test_information < ActiveRecord::Base
set_table_name = "test_information"
end
record = Test_information.find(:first)
当代码运行时我得到一个错误,它可以” t找到表test_informations。有一个名为test_information的表,我可以查询它,但不能用activerecord。
是否有一些神奇的咒语,我必须使用set_table_name?我的印象是,使用具有主动记录的现有模式非常简单...
任何想法?
由于提前,
--Robert
Doh!支付多想一点... 再次感谢您的帮助。 – RMatthews 2010-07-02 21:23:34