Kendall Buchanan wrote:
> I have a model w/ three validations in PaymentApplication:
>
> validate :total_applications_cannot_exceed_payment_amount
> validate :cannot_exceed_activity_price
> validates_numericality_of :amount
This might be a shot in the dark, I'm not completely sure what happens
when calling validate with the symbol following, but are you sure the
second call to validate override the first? I think there should be only
one custom validation method on a model that does all your custom
validations.
Try removing the second validate and add both symbols to one validate as
shown in this example:
class Invoice < ActiveRecord::Base
validate :expiration_date_cannot_be_in_the_past,
:discount_cannot_be_greater_than_total_value
def expiration_date_cannot_be_in_the_past
errors.add(:expiration_date, "can't be in the past") if
!expiration_date.blank? and expiration_date < Date.today
end
def discount_cannot_be_greater_than_total_value
errors.add(:discount, "can't be greater than total value") if
discount > total_value
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---