Rails: Money gem keeps defaulting to USD currency after saving
===

I'm using the [Money 5.0 gem][1] to give the user a choice of using their own currency to sell their stuff to locals. I've got the money part working but not the currency part.

My code looks like this (following some parts of the example [here][2]):

    # database
    t.string  "price_currency", :null => false
    t.integer "price_cents",    :null => false, :default => 0

    # model
    class Dress < ActiveRecord::Base
      attr_accessible :price_currency, :price
    
      def price
        Money.new price_cents || 0, price_currency || Money.default_currency
      end

      def price=(value)
        Money.parse(value).tap do |price|
          write_attribute :price_cents,    price.cents
          write_attribute :price_currency, price.currency_as_string
        end
      end
    end

    # form
    <%= f.select(:price_currency, all_currencies(Money::Currency.table)) %>
    <%= f.text_field :price %>

    # helper
    module DressesHelper
      def all_currencies(hash)
        hash.inject([]) do |array, (id, attributes)|
          array ||= []
          array << [attributes[:name], attributes[:iso_code]]
          array
        end
      end
    end

With this, the select tag does output all of the currencies by their name. When I'm trying to save the @dress with a different currency, the currency just get reverted to the default currency, USD.

The log output when saving:

    Started PUT "/dresses/2" for 127.0.0.1 at 2012-07-11 18:12:06 +0800
    Processing by DressesController#update as HTML
    Parameters: {"utf8"=>"✓", (some output omitted) "price_currency"=>"USD", "price"=>"879.236"}, "commit"=>"Save changes", "id"=>"2"}

I can change the currency directly in the rails console but when I tried to change it again in the browser, it just revert back to USD.

I've tried the solution by another [question][3] but it doesn't work. Most of other similar questions use the `composed_of` in the model but it was [removed][4] in the money gem. According to article [here][5], `composed_of` will be removed in Rails 4.

  [1]: https://github.com/RubyMoney/money
  [2]: http://stackoverflow.com/a/4800159/294869
  [3]: http://stackoverflow.com/questions/7988882/setting-currency-with-form-select-with-money-gem
  [4]: https://github.com/RubyMoney/money/issues/180
  [5]: http://blog.plataformatec.com.br/2012/06/about-the-composed_of-removal/