In my Rails 3 app, I am creating a Book model which contains an ISBN column. This ISBN value will be a number 13 characters long. Which type should I use to create the ISBN column? Should I use an :integer or a :string? What is the maximum size of an integer in Rails?
rails g scaffold Book title:string isbn:integer
The maximum size of the integer depends on the database being used. For MySQL it’s 2147483648 (2^31 since it’s an unsigned integer.) I would recommend you store the ISBN as a string (likely a CHAR(13) if possible.)