0

Can I use the t.money migration helper to create a column without a default currency?

  create_table :product do |t|
    t.money :price
  end

creates:

t.string   "price_currency",  default: "ZWL", null: false

but would like:

t.string   "price_currency",  null: false
Brian Low
  • 11,605
  • 4
  • 58
  • 63
  • If you really want control over that, why not do the migration manually like you're doing here? – tadman May 05 '15 at 16:48

2 Answers2

0

You can set other default currency (I think nil is allowed too) in money-rails initializer as described here.

# config/initializers/money.rb
MoneyRails.configure do |config|

  # set the default currency
  config.default_currency = nil

end

if it won't works try to specify nil for default key in config.currency_column option:

config.currency_column = { prefix: '',
                            postfix: '_currency',
                            column_name: nil,
                            type: :string,
                            present: true,
                            null: false,
                            default: nil
                         }
willis
  • 189
  • 7
0

Try defining the default

t.money :price, default: nil
Ismael Abreu
  • 16,443
  • 6
  • 61
  • 75