CanCanCan displays localised flash messages if a resource is not authorised.
https://github.com/CanCanCommunity/cancancan/wiki/Translations-(i18n)
# en.yml
en:
unauthorized:
manage:
all: "You do not have access to %{action} %{subject}!"
I have dug through the GitHub repo, but I can't figure out how the subject variable is defined.
From the output, I would guess that subject is defined as something like object.class.name.underscore.
I want to alter this to use object.model_name.human.
This would make it much more consistent with Rails conventions, and easier to localize.
en:
activerecord:
models:
mymodel: MyLocalizedSubjectName
Can someone point me to code that defines subject, or suggest how I can patch CanCanCan to use localized model names?