Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: ActiveRecord: method find Segmentation fault
bin liu
12/22/2004 2:31:00 AM
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.basec...
-- Web-based Project Management
http://www.rubyon...
-- Web-application framework for Ruby
http://macro...
-- TextMate: Code and markup editor (OS X)
http://www.loudthi...
-- Broadcasting Brain
_______________________________________________
programming is my life
my blog:
http://blog.itpub....
http://www.ru...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: ActiveRecord: method find Segmentation fault
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password