On Wed, Aug 20, 2008 at 5:36 PM, <brabuhr / gmail.com> wrote: > On Wed, Aug 20, 2008 at 5:01 PM, Nick Brown > <ruby-forum.com / nick-brown.com> wrote: >> "puts #{a}" outputs the modified version of a, but inserting that *exact >> same* string object into a database puts an UNMODIFIED version of the >> string into the DB. It's as if db.execute looks back in time to before >> the sub! when it gets the value of a. Something unexplained is going on >> here (unless the database module includes a time machine). > > p self.class, "bind_params()" > p bind_vars > p *bind_vars > bind_vars.flatten.each do |var| > p var irb(main)> cgi = CGI.new('html4') (offline mode: enter name=value pairs on standard input) a=hi => #<CGI:0xb7c367b8 @params={"a"=>["hi"]}, @multipart=false, @output_cookies=nil, @output_hidden=nil, @cookies={}> irb(main)> a = cgi['a'] => "hi" irb(main)> a.sub!(/hi/, 'bye') => "bye" irb(main)> a => "bye" irb(main)> [a] => ["bye"] irb(main)> [a].flatten => ["hi"]