Rails 3 full error messages format Rails 3 full error messages format ruby-on-rails ruby-on-rails

Rails 3 full error messages format


Change your current code

<% @object.errors.full_messages.each do |msg| %>  <li><%= msg %></li><% end %>

With this

<% @object.errors.messages.values.each do |msg| %>  <% msg.each do |m| %>    <li><%= m %></li>  <%end %><% end %>

And in your model customize the message:

validates :attribute, :presence => { :message => 'Attribute cannot be blank' }


don't know if it can help, but a locale file for Bulgarian is available on Github.

you may also try this (should work according to rails guides):

bg:  errors:    format: "%{message}"    messages: &error_messages      empty: "Something something %{attribute} something something"

this blog post and this stack overflow issue also talk about weird {{attribute}} {{message}} structures. Seems caused by a conflict between two I18n gems installed on the same server.


Returns all the full error messages for a given attribute in an array.

@object.errors.full_messages_for(:name)

=> ["Name is too short (minimum is 5 characters)", "Name can't be blank"]