Trouble converting string to int

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

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?!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs