0

I have a model

class News < ActiveRecord::Base
  serialize :types, Array
end

My Migration is

create_table "news"  do |t|
   t.string     "types"
end

Usually we are giving

t.text  "types"

But here only 3 types are there. So I need mysql to be allocated small space for types. So can I give

t.string     "types"

or some limit for an array serialize ?

Abhi
  • 3,361
  • 2
  • 33
  • 38
  • Have a look at this: http://stackoverflow.com/questions/3565557/rails-serialize-value-as-comma-seperated-and-not-as-yaml – vee Dec 24 '13 at 07:28

1 Answers1

0

To a first order, based on some limited tests, yes, you can use string instead of text as a schema type for serialized attributes.

Peter Alfvin
  • 28,599
  • 8
  • 68
  • 106