So you can change an error message in en.yml with something like the following:
en:
activerecord:
errors:
models:
foo:
attributes:
amount:
greater_than_or_equal_to: "Custom GTOE error message."
However, this will say the following:
Amount Custom GTOE error message.
I know I can remove it globally with:
en:
activerecord:
errors:
format: "%{message}"
But can I remvoe the %{attribute}
for only this validation?
Thanks!
I'm not sure if you can remove it from the en.yml, but you could make a custom one that I think would have the signature you want:
def discount_cannot_be_greater_than_total_value
if attribute > total_value
errors.add(:base, "can't be greater than total value")
end
end
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