From: Mark Hubbart Date: 2004-02-14T12:45:06+09:00 Subject: Re: cgi params in ruby On Feb 13, 2004, at 4:44 PM, Cere Davis wrote: > > I agree with you about the cgi syntax strangeness. If you want to > hand enter tag syntax you have to someone splice it in the cgi object > instance and this sort of seems like to heavy of a burned to put on > the end user who just wants to write some simple code. Maybe it's > just my ignorance but I've found this package to be pretty inflexible. > > related to that actually... > > I wanted to just print labels before the text_field statements so that > one can see the title of the text field that they are filling in. here: # You want the following code block to return a string each time; # it'll map to an array of strings, which you join at the end into one string: cgi.params.map {|key, val| # cgi.print immediately outputs what you pass it, rather than # adding it to the string. just stick a string in there: key + " :" + cgi.text_field(key, val.to_s) + cgi.br }.join + # and join the result before moving on cgi.submit("Okey Dokey?") And that should do what you want. Everything is a string; the #title and #text_field are just shortcuts for creating the html tags. They always take strings and return strings. Cheers, Mark