'Rails i18n inflections for error messages
Does anyone know how to define a gender for the attributes in a model? So when error messages appear I can give them a specific gender such as:
La dirección no puede estar en blanco ( Address can't be left blank) - Address has a female article in Spanish
El usuario no puede estar en blanco ( User can't be left blank) - User has a masculine article in Spanish
All of this obviously using i18n inflections in a specific rails /config/locales/language.yml file
I'm working with the actual attributes from my model so when I use things such as:
app/views/tableName/new.html.erb
<% if @tableName.errors.any? %>
<h2>Los siguientes errores no permitieron que se salvara este elemento</h2>
<ul>
<% @tableName.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
<% end %>
I can get a article (based on gender) before the actual message, the problem is that as you can see I really don't have access directly to the attributes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|