title: Using money-rails: How to manually set an attribute's currency
body: <p>I'm currently using:</p>
  
  <ul>
  <li>money-rails <code>v0.12.0</code></li>
  <li>rails <code>v4.1.6</code></li>
  <li>ruby <code>v2.1.3</code></li>
  </ul>
  
  <p><strong>Use case</strong></p>
  
  <p>I'm updating a money type attribute called <code>dollars_per_month</code>, which I created with the <code>money-rails</code> migration helpers (i.e <code>add_money</code>).</p>
  
  <p>So, in my model I have:</p>
  
  <pre><code>monetize :dollars_per_month_cents, allow_nil: true
  </code></pre>
  
  <p>And my current schema has:</p>
  
  <pre><code>t.integer  "dollars_per_month_cents"
  t.string   "dollars_per_month_currency", default: "CAD", null: false
  </code></pre>
  
  <p>Currency is set globally in config/initializers:</p>
  
  <pre><code>config.default_currency = :cad
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>I want the user to be able to enter "500 USD" OR "500" OR "500 CAD" in a text field, and have it save properly. Currently, when a non-global currency is specified, it throws the exception:</p>
  
  <pre><code>RuntimeError: Can't change readonly currency 'CAD' to 'USD' for field 'dollars_per_month'
  </code></pre>
  
  <p>Which makes sense- I can understand why this is naturally enforced.</p>
  
  <p>However.. I want to forcibly change the currency <em>without</em> caring about such enforcements because this field is merely there for capturing the answer to a question.</p>
  
  <p>The simple solution (despite the future lack of convenience) is to turn this into plain text. However, I am wondering if it is possible to do this with RubyMoney and/or money-rails without touching the rest of the app.</p>
  
  <p><strong>Notes</strong></p>
  
  <ul>
  <li><p>I've tried changing <code>dollars_per_month_currency</code> and saving the model, however, <code>dollars_per_month</code> still returns a CAD based Money object.</p></li>
  <li><p>I've looked into Instance Currencies in the money-rails <a href="https://github.com/RubyMoney/money-rails#instance-currencies">readme</a>. While I believe I could make this work, I feel it is overkill because it requires extra currency fields.. when I just want to change <code>dollars_per_month_currency</code>.</p></li>
  </ul>
  
  <p>Appreciate any insights or experience anyone has to share!</p>