# Trouble converting string to int

**URL:** <https://www.ruby-forum.com/t/trouble-converting-string-to-int/133505>\
**Category:** Rails\
**Created:** [April 1, 2008, 5:09am UTC](https://www.ruby-forum.com/t/trouble-converting-string-to-int/133505 "2008-04-01T05:09:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [April 1, 2008, 5:09am UTC](https://www.ruby-forum.com/t/trouble-converting-string-to-int/133505/1 "2008-04-01T05:09:51Z")

</div>

Hi. I’m trying to perform the following comparison

if (params[:bid][:points] \<= session[:user][:points])

But I get the following error

“comparison of String with 0 failed”

I have tried changing the code to this

if (params[:bid][:points].to\_i \<= session[:user][:points])

But now I get  
“too few arguments”

Can anyone see what’s wrong? Surely this should be a pretty simple  
thing?  
Thanks

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [April 1, 2008, 2:40pm UTC](https://www.ruby-forum.com/t/trouble-converting-string-to-int/133505/2 "2008-04-01T14:40:08Z")

</div>

Dan S. wrote:

> Hi. I’m trying to perform the following comparison  
> …  
> if (params[:bid][:points].to\_i \<= session[:user][:points])
> 
> But now I get  
> “too few arguments”
> 
> Can anyone see what’s wrong? Surely this should be a pretty simple  
> thing?  
> Thanks

try a puts on params[:bid][:points] and session[:user][:points] to see  
what it gives, because I guess that one of this 2 vars is nil?!
