title: How do I determine if a string is numeric?
body: <p>I thought this would be easier to find, but I'm quite surprised that it isn't.</p>
  
  <p>How on Earth do I test if a string is a number (including decimals) outside a Model?</p>
  
  <p>e.g.</p>
  
  <pre><code>is_number("1") # true
  is_number("1.234") # true
  is_number("-1.45") # true
  is_number("1.23aw") #false
  </code></pre>
  
  <p>In PHP, there was <code>is_numeric</code>, but I can't seem to find an equivalent in Ruby (or Rails).</p>
  
  <p>So far, I've read the following answers, and haven't gotten any closer:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/4173530/ruby-on-rails-validate-a-cost">Ruby on Rails - Validate a Cost</a></li>
  <li><a href="https://stackoverflow.com/questions/24098990/ruby-rails-how-can-you-validate-against-decimal-scale">Ruby/Rails - How can you validate against decimal scale?</a></li>
  <li><a href="https://stackoverflow.com/questions/6039378/invalid-decimal-becomes-0-0-in-rails">invalid decimal becomes 0.0 in rails</a></li>
  </ul>