Saturday, July 29, 2006

Comparison of String with Integer failed

If you have code like


@category_id=get_id_from_permalink(@params[:permalink_id]);
if @category_id >=1
....
end

then you will get the following error:

comparison of String with 1 failed


To fix the error modify the above code so it is something like:

if @category_id.to_i >=1
....
end

2 Comments:

At 7:03 AM, Blogger Mike Murdock said...

Will I have to add '.to_i' to every single instance of the variable I use?

 
At 7:04 AM, Blogger Mike Murdock said...

Will I have to add '.to_i' to every single instance of the variable I use?

 

Post a Comment

<< Home

eXTReMe Tracker