I'm using
validates :feed_id, presence: true, uniqueness: true
How should I be generating a custom error message to specify that the user has already subscribed to this feed (the feed_id) field is a duplicate
I know I can just do validate_uniqueness_of but it would clutter up the code unnecessarily. How do I pass a specific error message if uniqueness validation fails??
Put a hash with the key message
and desired message as the value instead of true
:
validates :feed_id, presence: true, uniqueness: {message: "already subscribed"}
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