Last week I was reading a chapter in a RailsSpaces book and because the book was written in 2007 the code was a bit outdated. The issue that I was running into was the author was using the sprintf() function to format a string that is part of the ActiveRecord error messages. This is a problem because the ActiveRecord uses error messages such as :

“is too short (minimum is {{count}} characters)”

where the word in the double curly braces is the placeholder for the value that the developer must replace. I first thought that I simply was not using the sprintf() function correctly until I discovered that the sprintf() was the wrong method to use in the first place. What should be used is a new class that was introduced to Rails in version 2 called I18n which is a new way of localizing the text in rails applications. The correct way of formatting those kinds of messages in Rails now is:

				:count=> some_value)