Quick question.
I’m kind of a novice to Rails and have been teaching myself using
RailsSpace which has examples based on an older version of Ruby/Rails.
I’ve been able to adapt them all but there was one question I had
regarding testing error_messages. I’ve noticed that the error_messages
in activeRecord have been changed due to internationalization. Not only
that but in previous versions of Rails, the error message strings were
of the form
:too_short = “…(minimum is %d characters)”
Which made it easy to print with the correct value by using
sprintf(@error_messages[:too_short], 15)
But it seems that now they are of the form:
:too_short = “…(minimum is {{count}} characters)”
Which cannot be as simply processed. They only way I’ve dealt with this
is to use:
min_length = 15
@error_messages[:too_short]["{{count}}"] = “#{min_length}”
I’m wondering if there is, it seems like there would be, an easier way
of replacing the {{count}} portion of the error string.
Any help would be greatly appreciated on this.