I have an address model and am doing some validations. One of them seems
to ignore :allow_nil => true. If I leave the phone input blank, I get
it back with a "too short" error. Here''s the relevant parts
of the model:
1. class Address < ActiveRecord::Base
2.
3. validates_length_of :phone, :in => 7..10, :allow_nil => true
4.
5. before_validation :format_phone
6.
7. def format_phone
8. unless self.phone.nil?
9. self.phone.gsub!( /[^0-9#\*]/, '''' )
10. self.phone.gsub!( /^1/, '''' )
11. end
12. end
13.
14. end
So, why isn''t the model doing what it''s supposed to?
Thanks,
--Dean
--
Unscrambler of eggs.
-------------------------------------------------------------------------------
Work is the curse of the drinking class -- Oscar Wilde
Fermentation fault (Coors dumped)
In vino veritas