From: Julian Leviston Date: 2008-04-03T17:04:51+09:00 Subject: Re: ArgumentError even if variable is set Yes, cgi.params is an array, but cgi.params["numdomains"] shouldn't be. Julian. Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO (#2) OUT NOW! http://sensei.zenunit.com/ On 03/04/2008, at 7:01 PM, Prabhas Gupte wrote: > Julian Leviston wrote: >> That's because your params["numdomains"] is returning a blank array, >> so technically it's not empty. to_i is a method of the string class. >> >> you could put >> >> params["numdomains"].to_s.to_i >> >> But I don't know why your numdomains is returning an array?? >> >> Julian >> >> >> Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO >> (#2) OUT NOW! >> http://sensei.zenunit.com/ > > cgi.params is an array. And to_i method does not work on arrays. > And contents at each array index are also not strings. Hence, it is > needed to convert them to string first and then use to_i. > to_s works on any object. > -- > Posted via http://www.ruby-forum.com/. >