Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying string fields length on Ruby on Rails

I'm not able to generate string fields with a specified length in a migration. They are always created with 255 character-length.

Anyone knows?

like image 558
David Morales Avatar asked Dec 14 '11 09:12

David Morales


1 Answers

I think you're looking for the :limit option:

class CreateUser < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :name, :limit => 10
    end
  end
end

Reference

like image 123
Chowlett Avatar answered Nov 15 '22 08:11

Chowlett