Here is my schema.rb
create_table "users", force: true do |t|
t.string "name", limit: 6
t.string "email"
t.datetime "created_at"
t.datetime "updated_at"
end
I set the limit fo string for the column "name".
Then, in console:
user = User.new(name:"1234567890",email:"username@gmail.com")
user.save!
It raised the error:
ActiveRecord::StatementInvalid: Mysql2::Error: Data too long for column 'name' at row 1: INSERT INTO `users` (`created_at`, `email`, `name`, `updated_at`) VALUES ('2014-06-19 15:08:15', 'username@gmail.com', '1234567890', '2014-06-19 15:08:15')
But, when I switched to rails 3.
I found it truncated the string "1234567890" automatically, and inserted "123456" into database without error.
Is there anything about this has been removed in rails 4?
Should I add some truncate functions in the model by myself? Thanks!