Martin Luy wrote:
validates_format_of :name, :with => /\A(\w(?:[/’ -.])?)*\Z/i
What does the ‘i’ do at the end of the regular expression?
It makes the match case insensitive
Should I do validation for attributes that are not from a form?
Yes. If you expect a field to conform to condition that is not inherent
in it’s column type you should validate the data. It will catch bugs
and keep you data more coherent.
create_table :customers do |t|
t.column :number, :integer, :limit => 4
As far as I know, Mysql 5.0.27 uses Int for number here. Will also a
small number need 4 bytes in the database?
Yes. It really isn’t a big deal. There are ways around this, but
before you go hacking into the code ask yourself if this isn’t premature
optimization. unless you are storing ~10^6 rows your space savings will
not be appreciable.
J. F. Miller