Ruby(不是Rails)在使用find()时给出NoMethodError

Nat*_*teD 0 ruby mysql activerecord osx-snow-leopard

我有几个脚本使用ActiveRecord与MySQL数据库交互而没有其余的Rails包(尽管我已经安装了完整的Rails gem).但是,当我尝试在ActiveRecord-descended类上调用find()时,最近尝试使用这些类已经给了我NoMethodError.
类代码非常基本:

class LineItem <ActiveRecord::Base
   set_primary_key 'id'
   set_table_name  "line_items"
end
Run Code Online (Sandbox Code Playgroud)

是的,因为我使用的是MySQL数据库,所以我有一个db连接器文件:

require 'rubygems'
require 'active_record'
require 'logger'
ActiveRecord::Base.establish_connection(
  :adapter =>'mysql',
  :database=>'my_db',
  :username=>'my_user',
  :password=>'a_password',
  :host=>"ip_address",
  :port=>3306
)
ActiveRecord::Base.logger = Logger.new(STDERR) 
Run Code Online (Sandbox Code Playgroud)

但是当我运行脚本时:

require "dbconn"
require "lineitem"

li = LineItem.new()
li.find(1)
Run Code Online (Sandbox Code Playgroud)

我收到错误:

NoMethodError: undefined method `find' for #<LineItem id: nil, trans_id: nil, trans_code: nil, data: nil>
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/attribute_methods.rb:260:in `method_missing'
from (irb):4
Run Code Online (Sandbox Code Playgroud)

如果有人有任何建议我会很感激.我在OSX 10.6.1上使用Ruby 1.8.7是的,它在10.5.x上运行良好

hrn*_*rnt 5

不是find类方法而不是实例方法?