Define the size of a field in the migration

0

How do I set the size of a field of type string in a migration? Ex:

class CreateRooms < ActiveRecord::Migration
def change
create_table :rooms do |t|
  t.string :title
  t.string :location
  t.text :description

  t.timestamps
end
end
end

How can I say that the title field is varchar (50)

    
asked by anonymous 16.10.2014 / 05:31

1 answer

0

Use the limit :

t.string :title, limit: 50

Official documentation here: link

    
16.10.2014 / 13:38