title: Validating an attribute to be an integer only
body: <p>product.rb model file:  </p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    validates_numericality_of :price
    validates_numericality_of :stock, if: Proc.new { |p| (p.stock.is_a? Integer and p.stock &gt;= 0) ? true : false }
  
    def price=(input)
      input.delete!("$")
      super
    end
  end  
  </code></pre>
  
  <p>I want stock to be integer only. When I submit stock with float value say 34.48 then in Insert sql cmd in server log, I see 34 only, and it doesn't hit the validation condition above, how is this possible that the validation condition is being true even i send float number.(new to rails, hoping this question makes sense).</p>