From: dolio@... (Dan Doel) Date: 2003-08-05T07:37:19+09:00 Subject: Re: Incompatible changes to cgi.rb in 1.8.0 What about: if @cgi.has_key? 'foo' ... do stuff end Brian Candler wrote in message news:<20030804170401.A31567@linnet.org>... > Hmm, something has changed in CGI which has broken an application - sorry I > didn't have a chance to test/comment on this before 1.8.0 was released, but > anyway here's the information now. > > @cgi['foo'][0] used to return nil if parameter 'foo' was not supplied by the > user. It now returns empty string; so does @cgi['foo'] > > This is a bit of a problem, since I have code which says > > if @cgi['foo'][0] > .. do stuff if parameter 'foo' is supplied > end > > in lots of places. But in any case, surely "parameter is missing" should be > represented by nil, since the condition "parameter is present but is an > empty string" is different? > > The solution I have found is > > if @cgi.params['foo'][0] > .. > endif > > But that seems to be rather against the spirit of the change to the cgi.rb > module, which was supposed to make accessing parameters *easier*, not more > convoluted... > > Cheers, > > Brian.