I'm seeing linting errors from Rubocop and I'm not quite sure how to fix one:
Example taken from Rubocop for Rails/i18nLocaleTexts
# bad
class User < ApplicationRecord
validates :email, presence: { message: "must be present" }
end
# good
# config/locales/en.yml
# en:
# activerecord:
# errors:
# models:
# user:
# blank: "must be present"
class User < ApplicationRecord
validates :email, presence: true
end
But what if the error is on a uniqueness validation in the Department model like:
# app/models/department.rb
...
validates :role, uniqueness: { scope: :company, message: 'admin is already present' }, if: -> { role_admin? }
Tried:
# en.yml
activerecord:
errors:
models:
publication:
attributes:
base:
must_be_in_future: Release date must be in future
department:
uniqueness: admin is already present
...
...and then how to rewrite the validates :role, uniqueness: ... statement above to include the localized text?