title: Storing a percentage in Rails + MySQL
body: <p>I need to use a percentage in my Rails app.  In any view, including when it is entered by the user, the format will need to be the hundreds format, <code>100.000</code>.  When it's used in calculations, it needs to be represented in the hundredths format, <code>1.00000</code>.</p>
  
  <p>My migration (I'm adding the column to an existing table) has the following line:</p>
  
  <pre><code>add_column :worker, :cash_split, :decimal, :precision =&gt; 6, :scale =&gt; 5
  </code></pre>
  
  <p>So, as of right now, I'm storing it in the hundredths (<code>1.00000</code>) format. My basis for choosing to store it in this format is that i figure it will mean cleaner business logic (i.e. no <code>worker.cash_split / 100.0.to_d</code> code hanging around) when i need to do multiplication.</p>
  
  <p>My only other thought was maybe abusing the composed_of method.  I could store the data in the hundreds (<code>100.000</code>) format as cash_split and then make an attribute accessor <code>cash_split_percentage</code> that returns <code>cash_split</code> in its 1.0000 format counterpart.</p>