如何在Rails迁移中使用UTF8字符?

时间:2011-12-16 17:46:34

标签: ruby-on-rails-3 rails-migrations

创建一个具有如下迁移的简单模型将破坏rake db:migrate任务:

class CreateProducts < ActiveRecord::Migration
  def change
    create_table :products do |t|
      t.string :title
      t.float :price, :default => "0.00"
      t.string :currency, :default => "€"

      t.timestamps
    end
  end
end

EUR交换欧元符号会暂时解决问题,但总的来说,我很想了解如何使用作为默认值。

干杯

1 个答案:

答案 0 :(得分:3)

将它放在迁移文件的第一行:

# encoding: utf-8