Model.errors.add ... No attribute

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.

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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs