Reputation: 171
I have this scenario, the person
object has aprice
.
When I try to destroy the price
that is being used byperson
, I can not because it is dependent :: restrict_with_error
. (This is expected)
I use yml files to translate error messages from English to Portuguese. But the relationship in the plural is not translated.
Relationship price has_many: people person belongs_to: price
Example:
obj_price.errors.messages: Não é possível excluir o registro pois existem people dependentes
I expected people to be translated to pessoas
price.rb
class Price < ApplicationRecord
has_many :people, dependent: :restrict_with_error
end
person.rb
class Person < ApplicationRecord
belongs_to :price
end
price.yml
pt-BR:
activerecord:
models:
price: Tabela de Preços
prices: Tabelas de Preços
attributes:
price:
name: Nome
person.yml
pt-BR:
activerecord:
models:
person: Pessoa
people: Pessoas
attributes:
person:
id: ID
name: Nome
price_id: Tabela de preços
Upvotes: 1
Views: 506
Reputation: 466
According to the rails documentation you should use one
for singular and other
for plural.
So in your person.yml
pt-BR:
activerecord:
models:
person:
one: Pessoa
other: Pessoas
attributes:
person:
id: ID
name: Nome
price_id: Tabela de preços
Upvotes: 2