From: bin liu Date: 2004-12-22T11:31:27+09:00 Subject: Re: ActiveRecord: method find Segmentation fault require "active_record" class Customer < ActiveRecord::Base def self.table_name() "customer" end end ActiveRecord::Base.establish_connection( :adapter => "mysql", :host => "localhost", :username => "root", :password => "root1234", :database => "bookstore" ) cs=Customer.find_all this code also has errors(mysql server version is 4.1): C:\dev\bookstore\test>ruby customer.rb c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.2.0/lib/active_record/connection_a dapters/mysql_adapter.rb:129: [BUG] Segmentation fault ruby 1.8.2 (2004-11-06) [i386-mswin32] >> c=Customer.new(\"name\"=>\"liubin\",\"password\"=>\"passwd\") > c.save > puts \"new id is \"+c.id.to_s > cs=Customer.find(2) > cs.each{|c| puts \"user #{c.name} has password #{c.password}\"} If you want Customer to return an array, you need to ask it with one, like: customers = Customer.find([2]) customers.each { |c| puts "user #{c.name} has password #{c.password}" } You also don't want to escape the quotes as you did in the example. I don't know why Ruby crumbles and dies on it, though. Seems a bit excessive ;) -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain _______________________________________________ programming is my life my blog:http://blog.itpub.net/liubin http://www.ruby-cn.org/