simple validation problem

validates_numericality_of :price

protected
def validate
errors.add(:price, “error mesage”) unless price.nil? || price >= -180 || price <= 180
end

Adapted from ze Rails book.
Should work,

Vish

errors.add(:price, “error mesage”) unless price.nil? || price >= -180 && price <= 180

The test won’t happen if price.nil? which is logical. validates_existence_of could take into account that condition as well.

Vish