Rails 3: How to validate that A < B where A and B are both model attributes ?
- by Misha Moroshko
I would like to validate that customer_price >= my_price. I tried the following:
class Product < ActiveRecord::Base
attr_accessor :my_price
validates_numericality_of :customer_price, :greater_than_or_equal_to => my_price
...
end
(customer_price is a column in the Products table in the database, while my_price isn't.)
Here is the…