Hello -- On Fri, 20 Sep 2002, Matthew, Graeme wrote: > Hi all, me again, jeez im clocking up some traffic, sorry Don't worry -- see my last post if you want to see real filler :-) > thanks for all your help before, it was just me been stupid and leaving out > an enclosing quote for the hash key lookup doh ! > > Im from a perl background so im having some trouble as I am not used to > having to check my data types You shouldn't have to do that much at all in Ruby. > for example , I have my CGI script > > cgi = CGI.new > id = cgi['id'] > > prj = Project.new(id) > print prj.DisplayProject > > when I print id.type is states that it is an array ? id will indeed be an Array here -- that's how the CGI library stores the params. So... you need to do: id = cgi["id"][0] or id, = cgi["id"] # note the comma to get the first element. (There's been a lot of discussion in recent months about making it easier to get at the first element in cases where the array only has one element. I don't remember where that stands exactly.) > my project class needs to check the value of id because if it is passed as a > valid ie > 0 integer then the user is requesting you to load the data for > the project, the problem is it never fails below so when no id is passed > then it still tries to execute the SQL I don't know if it matters here, but don't forget that id will actually be a string, and you have to convert it if needs to be an integer (with to_i). David -- David Alan Black | Register for RubyConf 2002! home: dblack / candle.superlink.net | November 1-3 work: blackdav / shu.edu | Seattle, WA, USA Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com