I've set up a validation rule on my Product
model to check that two fields, name and quantity, are unique. For example, you can have
- Oreos 12-pack
- Oreos 100-pack
And both are valid entries. However, you can't have two Oreos 100-pack records.
I have used the approach described in this question to set up the rule (Validate uniqueness of multiple columns), however the default error message simply highlights the first field and says it's already taken, which does not accurately describe the problem to a user trying to insert product information.
If this is the general Rails solution to validating uniqueness on multiple fields, how can I set up the validation message appropriately depending on which rule has failed.
If there are other solutions that will automatically display an appropriate error message, what would it be?