Hi all,
Please be patient, I''m a newbie on rails (this is my first week on it).
I
was having some trouble with validates_length_of, specifically, when using
the :within option.
I couldn''t get :too_long and :too_short to over-ride the defaults. So I
took
a look at the code and realized that for the :within option, rails is
calling validates_length_of :minimum and then validates_length_of :maximum
but it doesn''t pass on the :too_long or :too_short options. So I made a
quick fix.
OLD:
case option
when :within, :in
raise ArgumentError, '':within must be a Range'' unless
option_value.is_a?(Range) # ''
validates_length_of attrs, :minimum => option_value.begin, :allow_nil =>
options[:allow_nil]
validates_length_of attrs, :maximum => option_value.end, :allow_nil =>
options[:allow_nil]
NEW:
case option
when :within, :in
raise ArgumentError, '':within must be a Range'' unless
option_value.is_a?(Range) # ''
validates_length_of attrs, :minimum => option_value.begin, :allow_nil =>
options[:allow_nil], :message => options[:too_short]
validates_length_of attrs, :maximum => option_value.end, :allow_nil =>
options[:allow_nil], :message => options[:too_long]
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails