Hi all, I was trying to update the JIS-encoded text in the databse to UTF-8 text but failed (For simplicity, I use "hello" & "world" in the test program below). Please point me the mistake I made here. Thanks.
#using sqlite ActiveRecord::Base::establish_connection (:adapter=>"sqlite3",:dbfile=>"the.db") #try to do the update but failed rowid = 72 #it is the default unique ID in sqlite Basic.find(:all , :select=>"rowid , event_name ,text ", :conditions=>["rowid = ?",rowid]).each do |o| puts "before modify" puts o.event_name puts o.text o.event_name = "hello" o.text = "world" puts "after modify before save" puts o.event_name puts o.text o.save #o.update_attribute(:event_name,"hello") end #confirm Basic.find(:all , :select=>"rowid , event_name ,text ", :conditions=>["rowid = ?",rowid]).each do |o| puts "after save" puts o.rowid puts o.event_name puts o.text end output Log : -->before modify |⒏Ⅲ罐る鸏1B2nrDJ0楦?6I!Aん赏发!!摅矿Eg!A? B?L1B2琂k楣|ん赏发贽罂驟g鶭6Ah,@d(:?}踌耷?>@7<T螥i?M駾6国L1B2M;OB騆\;X?c<T10?M?|楦? I r;O a??c-DJNJ3F.rDI&? -->after modify before save hello world -->after save 72 |⒏Ⅲ罐る鸏1B2nrDJ0楦?6I!Aん赏发!!摅矿Eg!A? B?L1B2琂k楣|ん赏发贽罂驟g鶭6Ah,@d(:?}踌耷?>@7<T螥i?M駾6国L1B2M;OB騆\;X?c<T10?M?|楦? Ir;Oa??c-DJNJ3F.rDI&? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---