rails 6.1.6.1中,我有以下不推荐使用的警告

DEPRECATION WARNING: action_view.raise_on_missing_translations is deprecated and will be removed in Rails 7.0. Set i18n.raise_on_missing_translations instead. Note that this new setting also affects how missing translations are handled in controllers.

我试过了

I18n.config.raise_on_missing_translations = true

但这引发了一个例外

NoMethodError: undefined method `raise_on_missing_translations=' for #<I18n::Config:0x00007fb6b1b1ae08>

那么我如何设置它,在哪里设置它(例如,在初始化式中).

推荐答案

application.rb或特定环境中设置配置like this:

config.i18n.raise_on_missing_translations = true

Ruby-on-rails相关问答推荐

如何使用继承类 (STI) 获取 Ruby on Rails 类中基类的实例

rails4 未知编码名称 - CP720

Rails ActiveRecord:验证单个属性

价格字段的字符串、小数或浮点数据类型?

Rails ActiveRecord 查询日期范围

Rails 5:无法从参数中检索哈希值

Rspec 与 TestUnit

Rails:仅在创建时验证,或者当字段不为空时在更新时验证

Rails 中是否有 HTML 安全截断方法?

如何使用 Rspec 判断 ActiveJob 中排队的内容

通过 Ruby 或 Rails 的 LDAP

Rails Associations - has_many => :through - 但相同的模型

为什么 Ruby on Rails 使用 http://0.0.0.0:3000 而不是 http://localhost:3000?

如何仅使用 PostgreSQL 创建简单的模糊搜索?

长期运行项目中的 Rebase Rails 迁移

Rails 路由:GET 没有参数 :id

使用 ActiveRecord 获取列名

Sidekiq Rails 4.2 使用 Active Job 还是 Worker?有什么不同

Ruby 更新后:测试失败,assets资源 未声明为在生产中预编译

将数组传递到 hidden_​​field ROR