Djikiné
Djikiné

Reputation: 21

How to represent serialized fields in ActiveRecord::Base in ActiveRecord:Migration (Rails 2.3.16)

I'm new in rails. I read rencently how to serialize an array of string for example to store it in database.

class Fle < ActiveRecord::Base
   serialze :etat_fle

end

But i don't know how to represent this serialized field in the corresponding ActiveRecord::Migration Have someone an idea ?

Upvotes: 1

Views: 63

Answers (2)

Djikin&#233;
Djikin&#233;

Reputation: 21

As Major Major said, i have to declare the field like this in my migration file

t.column :type_fle, :text

and additionnaly i have to declare the field prefixed by the word serialize in my ActiveRecord::Base file

serialize :type_fle

Upvotes: 1

Kyle H
Kyle H

Reputation: 3293

Store it as a text. If the table is already created -

add_column :table, :column, :text

Upvotes: 2

Related Questions