When you pass the parameter through Ajax, it's just a string. All you need is a format that Ruby can understand and cast to an integer.
Ruby understands integers of arbitrary length, so you can send it as 1234567890987654321
and call to_i
.
If you're interested in reducing the length of the string representation, you could convert it to base 36 (the highest base that Ruby can interpret) like this:
JS
var number = "1234567890987654321";
var bigNumber = str2bigInt(number, 10, 80); //10: input = Decimal
var bigNumber36 = bigInt2str(bigNumber, 36); //36: output = Base 36
console.log(bigNumber36);
//---> "9do1sjhjpei9"
Ruby
big_number_36 = '9do1sjhjpei9'
big_number = big_number_36.to_i(36)
puts big_number
# => 1234567890987654321