/ Published in: Ruby
validate :price_must_be_at_least_a_cent
protected def price_must_be_at_least_a_cent
errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01
end
protected def price_must_be_at_least_a_cent
errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01
end
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
validate :price_must_be_at_least_a_cent protected def price_must_be_at_least_a_cent errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01 end