Flowdock
method

validates_length_of

Importance_2
Ruby on Rails latest stable (v6.1.7.7) - 1 note - Class: ActiveRecord::Validations::ClassMethods
validates_length_of(*attr_names) public

Validates that the specified attributes match the length restrictions supplied. If the attribute is an association, records that are marked for destruction are not counted.

See ActiveModel::Validations::HelperMethods.validates_length_of for more information.

Show source
Register or log in to add new notes.
March 13, 2010
3 thanks

Can be used with has_many associations

You can also use this to validate that a has_many association has a specified number of records on the other end:

has_many :members

validates_length_of :members, :minimum => 1