Mike
Mike

Reputation: 137

Ruby on rails multiplication acting weird

When I do:

params[:page] * 10

It gives me 1111111111. I want it to return 10.

What am I doing wrong?

Upvotes: 1

Views: 97

Answers (1)

Logan Serman
Logan Serman

Reputation: 29880

String multiplication will repeat the string n times. params is always an array of strings in Rails, so you need to convert params[:page] to an integer first with to_i.

Upvotes: 3

Related Questions