method

validates_length_of

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.

1Note

Can be used with has_many associations

sjmadsen ยท Mar 13, 20103 thanks

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