# Model.errors.add ... No attribute

**URL:** <https://www.ruby-forum.com/t/model-errors-add-no-attribute/182515>\
**Category:** Rails\
**Created:** [January 29, 2010, 8:36am UTC](https://www.ruby-forum.com/t/model-errors-add-no-attribute/182515 "2010-01-29T08:36:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [January 29, 2010, 8:36am UTC](https://www.ruby-forum.com/t/model-errors-add-no-attribute/182515/1 "2010-01-29T08:36:44Z")

</div>

I _think_ that in activerecord-2.2.2\lib\active\_record\validations.rb  
that specifying the attribute as “” have the nice benefit of just adding  
the specified message that was supplied.

In activerecord-2.3.5\lib\active\_record\validations.rb not specifying an  
attribute causes a “interning empty string” error.

* * *

Is there a way in 2.3.5 to suppress the automatic generation of the  
error message. That is, in 2.2.2 I could do:

model.errors.add("", “Your email address (#{value}) has an invalid  
format.”)

This will fail in 2.3.5 with the above-mentioned “interning empty  
string”.

I think. I’m not sure. The code in 2.2.2 and 2.3.5 in this area if  
pretty different and my test beds in these two environments is pretty  
different.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [January 29, 2010, 12:58pm UTC](https://www.ruby-forum.com/t/model-errors-add-no-attribute/182515/2 "2010-01-29T12:58:10Z")

</div>

Ralph S. wrote:

> I _think_ that in activerecord-2.2.2\lib\active\_record\validations.rb  
> that specifying the attribute as “” have the nice benefit of just adding  
> the specified message that was supplied.
> 
> In activerecord-2.3.5\lib\active\_record\validations.rb not specifying an  
> attribute causes a “interning empty string” error.
> 
> * * *
> 
> Is there a way in 2.3.5 to suppress the automatic generation of the  
> error message. That is, in 2.2.2 I could do:
> 
> model.errors.add("", “Your email address (#{value}) has an invalid  
> format.”)
> 
> This will fail in 2.3.5 with the above-mentioned “interning empty  
> string”.
> 
> I think. I’m not sure. The code in 2.2.2 and 2.3.5 in this area if  
> pretty different and my test beds in these two environments is pretty  
> different.

Adding to the above …

Oh, geez, it looks like both the attribute and the message have to be  
symbols.

Is this some attempt to force interaction with I18N?
