I want to validate on update that :budget_price
is always greater than previous value existing in this column.
I make a check on client side by html5 but how I validate it in model.rb
I write
validates :budget_price, :numericality => { :greater_than => :budget_price }, :on => :update
But it doesn't work properly
Change your second :budget_price
to :budget_price_was
like
validates :budget_price, :numericality => { :greater_than => :budget_price_was }, :on => :update
About other methods, see also http://api.rubyonrails.org/classes/ActiveModel/Dirty.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With