This stub ( paritally plucked out of Rails Api ) lets you to validate wheter the parameter passed to the controller ( they always send stringified ) is numeric or not.
#!/usr/bin/env ruby
require 'test/unit'
class TestNumeric < Test::Unit::TestCase
def test_validate_numericality_of
def test_numeric?
assert "3".numeric?
assert !"a".numeric?
end
end
end
class Object
def numeric?
begin
return true if Kernel.Float(self)
rescue ArgumentError, TypeError
return false
end
end
end