vendredi 17 juin 2016

Accessing the model's attribute translations when displaying error

I've successfully created my he.yml to localize my model's attributes names, example:

      attributes:
       vendor:
        name: שם ספק
        counter_number: מספר חשבונית
        phone: טלפון
        address: כתובת

Now, displaying labels in forms using simple_form's f.input, displays it correctly, the translated value of each attribute.

the problem is, displaying errors after validation, using

<% @vendor.errors.each do |attribute, error| %>

|attribute| for error "counter_number" for example, is displayed: "counter_number". not the translated one at the locale file [which as i mentioned previously, configured and loaded successfully]. I appended errors in a ul.errors, as shown in this screenshot: enter image description here

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire