David Morales
David Morales

Reputation: 18064

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?

Upvotes: 6

Views: 8433

Answers (1)

Chowlett
Chowlett

Reputation: 46675

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

Upvotes: 14

Related Questions