これは、デフォルト値を設定した最初の移行です。
class CreateMove < ActiveRecord::Migration
def change
create_table :moves do |t|
...
t.text :move_types, :null => false, :default => [0]
...
end
end
end
そして、これはモデルです:
class Move < ActiveRecord::Base
serialize :move_types, Array
end
を呼び出すとMove.new
、次のようになります。
=> #<Move id: nil, move_types: "'---\n- 0\n'">
しかし、私が得るべきものは
=> #<Move id: nil, move_types: [0]>
実際、Move を作成してその MoveMove.create(move_types: [0])
をフェッチすると、これが返されます。