Forum: Ruby on Rails AR validates_uniqueness_of's :message

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Doug D. (Guest)
on 2007-07-31 06:15

Can anybody give me a hint on the format of :message? I have:

  validates_uniqueness_of :username, :scope => :group, :case_sensitive
=> false,
    :message => "%{fn} already exists in %{fn}."

I get "Userame already exists in Userame." Yuck!

When creating a duplicate with create(:username => 'userA', :group =>
'groupB'), how can I make it "userA already exists in groupB."  ???

By the way, where are the :message format and the usage of %{fn} and %d
documented? I've tried AWDWR 2nd ed., PickAxeII and Rails docs...

Thanks in advance!
Doug D. (Guest)
on 2007-07-31 22:42
Does anybody know where the usage %{fn} and %d in :message are
This topic is locked and can not be replied to.