title: Change comma to point type decimal in rails
body: <p>I have a model product, that model have attribute price with decimal type (<code>:precision =&gt; 20, :scale =&gt; 2</code>)
  In the form I use format for price field that looks like : <code>3.000,00</code>, When submitting the form, price change to <code>3.00</code> . I want the price to be <code>3,000.00</code>, not <code>3.00</code></p>
  <p>Test with rails console</p>
  <pre><code>irb(main):001:0&gt; p = Product.create(:price =&gt; &quot;3.000,00&quot;)   ←[1m←[36m
  (0.0ms)←[0m  ←[1mBEGIN←[0m   ←[1m←[35mSQL (72.0ms)←[0m  INSERT INTO
  &quot;products&quot; (&quot;created_at&quot;, &quot;price&quot; &quot;updated_at&quot;) VALUES ($1, $2, $3)
  RETURNING &quot;id&quot;  [[&quot;created_at&quot;, Tue, 29 Apr 2 014 14:07:25 WIB
  +07:00], [&quot;price&quot;, #&lt;BigDecimal:4c218f0,'0.3E1',9(18)&gt;], [&quot;updated_at&quot;, Tue, 29 Apr 2014 14:07:25 WIB +07:00]]   ←[1m←[36m
  (11.0ms)←[0m  ←[1mCOMMIT←[0m
  =&gt; #&lt;Product id: 8, price: #&lt;BigDecimal:4bd5588,'0.3E1',9(18)&gt;, created_at: &quot;20 14-04-29 07:07:25&quot;, updated_at: &quot;2014-04-29 07:07:25&quot;&gt;
   
  irb (main):002:0&gt; p.price.to_s
  =&gt; &quot;3.0&quot;
  </code></pre>
  <p>I have tried with <code>gsub</code> for change comma to point on <code>before_save</code> and store to database, but price always change to <code>3.00</code> on database.</p>
  <pre><code>  before_save :comma_to_delimiter
  
    def comma_to_delimiter
      self.price = self.price.gsub(/[.,]/, '.' =&gt; ',', ',' =&gt; '.')
    end
  </code></pre>
  <p>I want like this :
  when I input <code>3.000,00</code> to field price, on database <code>3,000.00</code> and on view price <code>3.000,00</code></p>
  <p>I can't figure out how to do that.
  Thanks</p>
  <p>Note : I'm using <a href="http://plentz.github.io/jquery-maskmoney/" rel="nofollow noreferrer">jquery-maskMoney</a> for field price with format :</p>
  <pre><code>$(&quot;#demo4&quot;).maskMoney();
  
  &lt;input type=&quot;text&quot; id=&quot;demo4&quot; data-thousands=&quot;.&quot; data-decimal=&quot;,&quot; data-prefix=&quot;R$ &quot; /&gt;
  </code></pre>