deepinder
deepinder

Reputation: 131

Activerecord Rails 3 string limits not working

I have a rails migration and I am most probably doing something incorrect here but the migration is ---

class CreateStates < ActiveRecord::Migration

def change

create_table :states do |t|
  t.string      :state_legacy_id
  t.string      :name, :length => 20
  t.string      :abbreviation, :length => 2
  t.timestamps
end
add_index   :states, :id

end

end

But when i go into mysql database and look at the table the name table as well as the abbreviation table have a length of varchar/ 255 What is about my limit statement that is incorrect.

I have tried both with and without quotes, so :limit => 20 and :limit => "20" both product tables with varchar 255.

Any suggestions will be welcome.

Thanks,

Upvotes: 0

Views: 486

Answers (1)

GracelessROB
GracelessROB

Reputation: 1048

i believe it's called limit - not length

e.g. :limit => 2

Upvotes: 1

Related Questions