ruby on rails - Error messages in nested attribute -


i've 3 models called account,user , accountpermission.

i'm creating account via accountpermission while creating user.

however, if problem occurs related account :name, system throws below.

account permissions account name has been taken

so, need fix error message.

i've tried add message attribute validation. appending actual message.

i've tried locale thing. still appending

en:   activerecord:     errors:       models:         account:           attributes:             name:               taken: 'bla bla' 

as far see in activemodel. message's structure comes below

locale/en.yml in activemodel

en:   errors:     format: "%{attribute} %{message}" 

so, there way edit message painless ? if delete model name, it's enough.

error message concatenated error , attribute name, account_permissions/account.name in provided error.

you can add locale attribute names so:

en:   activerecord:     attributes:       account: # model name         name: "name" 

or

en:   activerecord:     attributes:       account_permissions/account:         name: "account name" 

Comments