pagid
pagid

Reputation: 13877

How can I use UTF8 characters in Rails migration?

creating a simple model with a migration like the following will break the rake db:migrate tasks:

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

Exchanging the Euro sign with EUR fixes the issue temporary but in general I'd love to understand how I could work with as default value there.

Cheers

Upvotes: 1

Views: 1746

Answers (1)

Can Berk G&#252;der
Can Berk G&#252;der

Reputation: 113380

Put this on the first line of your migration file:

# encoding: utf-8

Upvotes: 3

Related Questions