Answer the question
In order to leave comments, you need to log in
How can I not write @entity.errors.add and still output the correct error messages from the locale?
My task is to display validation error messages in the form.
I can write my own error values in the controller and model, then there are no problems.
For example: @entity.errors.add :email, t('mongoid.errors.models.modern.entity.attributes.email.invalid') gives the message from the locale, but also writes 'is valid' separated by a semicolon
I want do it via locale without duplication.
Instead of an active record in the locale, I have mongoid.
And if I write @entity.errors.add :email, :invali in the controller.
Then it complains that locale: en.mongoid.errors.models.modern/entity.attributes.email.invali is not present.
That's right, there is no such locale.
But there is locale en.mongoid.errors.models.modern/entity.attributes.email.invalid
And there is a value: 'Ivalid format email'.
But he already writes not this value, but the value 'is invalid', which does not match my custom value in the locale.
Good thing I shouldn't have the line @entity.errors.add :email, :invalid
Messages should be displayed in the view without these entries in the controller.
But for some reason they do not take those values from the locale, but write 'is invalid'.
The locales and controller are in Engine Modern.
Question:
How can I not write @entity.errors.add with parameters and still print the correct error messages from the locale?
Yml is valid in locales
My guess is:
It might be Engine
It might be render action: :new
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question