Having a strange problem with a rails model I just created.
Here are my validations:
validates_presence_of :from_name, :message => \'Please provid
Go to dir_of_ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.x/lib/active_record/locale and edit the en.yml... replace the {{variable}} to %{variable}
Worked for me...
PS: maybe the path would be different for you. Adapt for you convenience.
I ran into this problem as well with an old 2.3.5 Rails app that I inherited. I had the 5.0 version of the i18n gem installed. I saw that it needs the %{} syntax. Doing this in config/locales/en.yml did the trick:
en:
activerecord:
errors:
full_messages:
format: "%{attribute} %{message}"
I'm working on a Rails 2.3.5 server at work that doesn't have i18n gem. The odd thing is that while my code works locally, I have this problem on the work server. And, another application I have with the same exact frozen gems does not display this problem on the work server.
I changed the activerecord en.yml file like above but also changed the actionpack en.yml file to get the error message title/header right:
\vendor\rails\activerecord\lib\active_record\locale\en.yml
#format: "{{attribute}} {{message}}"
format: "%{attribute} %{message}"
\vendor\rails\actionpack\lib\action_view\local\en.yml
activerecord:
errors:
template:
header:
one: "1 error prohibited this %{model} from being saved"
other: "%{count} errors prohibited this %{model} from being saved"
Also, I didn't bother with it but if you have error messages that contain counts, it looks like in the activerecord en.yml file you'd need to change the syntax of some of the messages too (like):
#too_long: "is too long (maximum is {{count}} characters)"
too_long: "is too long (maximum is #{count} characters)"
Upgrading to Version rails 2.3.9 fixes this problem
gem install -v 2.3.9 rails --include-dependencies
EDIT:
You also need to edit the config\environment.rb
file to change the RAILS_GEM_VERSION
.
RAILS_GEM_VERSION = '2.3.9'
EDIT #2:
I should note that version 2.3.9 is not the latest version of the 2.3.X branch, and you should upgrade the the latest version available.
so i keep seeing upgrading rails as the solution to this
... or you can simply downgrade i18n to version 0.4
as outlined in this post
getting {{attribute}} {{message}} in RoR views
cd <yourRailsProject>
gem install i18n -v 0.4.0 -i vendor/ -V
to install the i18n gem into the vendor folder (-V for verbose output, just to see what's going on under the hood)