title: Trouble converting money value to cents in Rails
body: <p>I story money values as integers like, price_in_cents or fee_in_cents. So, $1.00 would be stored in the database as 100.</p>
  
  <p>Internally, I've always just typed 100 in the form when I meant 1.00, but I thought it would be simple to convert a form input of 1.00 to 100 in the model, but I'm having trouble.</p>
  
  <p>No matter what I enter, I'm getting 0 for both values. Here's the model:</p>
  
  <pre><code>before_create :convert_money_to_cents
    attr_accessor :price, :fee
  
    private
  
    def convert_money_to_cents
      self.price_in_cents = price.to_i * 100
      self.fee_in_cents = fee.to_i * 100
    end
  </code></pre>
  
  <p>Any thoughts on why it's always coming up zero? I tried converting the string to various things (floats) and I'm still getting zeros.</p>