That's what I get for skimming...
We used lambda which I believe was already shown.
from Kete's app/models/choice.rb:
validates_uniqueness_of :label, :message => lambda {
I18n.t('choice_model.must_be_unique') }
Kieran, feel free to update with more info, if there are more details
to point out.
Cheers,
Walter
On Thu, Dec 16, 2010 at 9:07 AM, Walter McGinnis
<[email protected]> wrote:
> We've done it in the Kete app (http://github.com/kete/kete), but I
> can't recall the trick. I'll check with the guy that did it an see if
> he has an answer for you...
>
> Cheers,
> Walter
>
>
> On Thu, Dec 16, 2010 at 7:08 AM, Tom Ha <[email protected]> wrote:
>>> It may work for the default "keys" (for "validates_presence_of :name"
>>> the key would be "blank"), but not the custom ones.
>>
>> To sum it up: The solution is NOT to include any *custom* message keys
>> in the models, like...
>>
>> :message =>
>> I18n.t('activerecord.errors.models.my_model.attributes.whatever.please_select_whatever')
>>
>> The model will then apply the default message keys, for example
>> ":inclusion" in the case of "validates_inclusion_of"
>>
>> ...and in config/locales/en.yml you need to have:
>>
>> en:
>> activerecord:
>> errors:
>> models:
>> my_model:
>> attributes:
>> whatever:
>> inclusion: "Please select whatever." # see key:
>> "inclusion"
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>>
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.