# AR validates\_uniqueness\_of's :message

**URL:** <https://www.ruby-forum.com/t/ar-validates-uniqueness-ofs-message/110803>\
**Category:** Rails\
**Created:** [July 31, 2007, 4:15am UTC](https://www.ruby-forum.com/t/ar-validates-uniqueness-ofs-message/110803 "2007-07-31T04:15:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [July 31, 2007, 4:15am UTC](https://www.ruby-forum.com/t/ar-validates-uniqueness-ofs-message/110803/1 "2007-07-31T04:15:31Z")

</div>

Hello,

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!

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [July 31, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/ar-validates-uniqueness-ofs-message/110803/2 "2007-07-31T20:42:05Z")

</div>

Does anybody know where the usage %{fn} and %d in :message are  
documented?
