From: unbewusst.sein@... (=?ISO-8859-1?Q?Une_B=E9v?= =?ISO-8859-1?Q?ue?=) Date: 2007-10-12T08:00:15+09:00 Subject: Re: SQLite and ruby Sharon Rosner wrote: > Sequel lets you write stuff like this: > > require 'sequel/sqlite' > > # Open the database > DB = Sequel.sqlite('mydb.sqlite') > > # Assuming the table name is 'people' > class Person < Sequel::Model(:people) > def capitalize > p[:lastName].capitalize! > p[:firstName].capitalize! > p[:fullName].capitalize! > save > end > end I had to re-arrange your script the following way : class Person < Sequel::Model(:devicephonebook) def capitalize @values[:lastName] = @values[:lastName].name_capitalize @values[:firstName] = @values[:firstName].name_capitalize @values[:fullLastName] = @values[:lastName] + @values[:firstName] p "[ " + @values[:lastName] + ", " + @values[:firstName] + ", " + @values[:fullLastName] + " ]" #save end end i can't use String#capitalize! for three reasons : - 1 - if a name is already capitalize String#capitalize! returns nil ; - 2 - "aristocratic" people having name like that : di Girolamo Pavin de Lafarge von Beethoven van Houthen or composite name : - 3 - Harley-Davidson then i wrote : class String def name_capitalize if self.include?("-") l = self.split("-") l.each { |ll| ll = ll.capitalize } return l.join("-") elsif self.include?(" ") l = self.split(" ") l.each { |ll| ll = ll.capitalize if !TRUC.include? ll } return l.join(" ") else return self.capitalize end end end everything works well until i've uncomented "#save" where i get the same error as another script not using Sequel : RuntimeError: no such function: get_zy_string method hold in connection_pool.rb at line 68 method execute_insert in sqlite.rb at line 42 method insert in sqlite.rb at line 121 method save in record.rb at line 82 method capitalize in test-sequel.rb at line 38 at top level in test-sequel.rb at line 42 method [] in dataset.rb at line 330 method each in dataset.rb at line 330 method call in sqlite.rb at line 115 method fetch_rows in sqlite.rb at line 115 method each in resultset.rb at line 162 method fetch_rows in sqlite.rb at line 112 method query in database.rb at line 278 method execute_select in sqlite.rb at line 52 method hold in connection_pool.rb at line 62 method execute_select in sqlite.rb at line 52 method fetch_rows in sqlite.rb at line 109 method each in dataset.rb at line 330 method each in untitled document at line 1 method send in model.rb at line 60 method method_missing in model.rb at line 60 at top level in test-sequel.rb at line 42 Program exited. This appeared AFTER the first p in Person.each {|p| p.capitalize } ??? may be better to ask to the Sequel google-list but the prob does exist in sqlite3-ruby... -- Une B�vue