Rails 2.3 uniqueness validation - how can I capture the value causing the error
Posted
by sa125
on Stack Overflow
See other posts from Stack Overflow
or by sa125
Published on 2010-05-12T06:56:50Z
Indexed on
2010/05/12
7:04 UTC
Read the original article
Hit count: 487
Hi - I'm trying to capture the value that's throwing a uniqueness error (or for that matter, any other type of built-in validation) to display it in the :message
option. Here's what I tried (didn't work)
# inside the model
validate_uniqueness_of :name, :message => "#{name} has already been taken" # also tried using #{:name}
I could use a custom validation, but this beats the point of using something that's already integrated into AR. Any thoughts? thanks.
© Stack Overflow or respective owner