我有两个模型:
Category
has_many :inventories
Inventory
belongs_to :category
如果我正在创建类别并收到错误,则现在显示为:
Inventories unit of purchase can't be blank
我该怎么说呢?
Inventory unit of purchase can't be blank
我已经在en.yml中尝试了各种组合,并考虑了折线规则,但是似乎无法弄清楚这个窍门。
编辑
对于en.yml,我已经尝试过:
activerecord:
models:
inventory: "Inventory"
答案 0 :(得分:0)
假设Inventory
的属性名称为unit_of_purchase
,应该这样做
en:
activerecord:
errors:
models:
inventory:
attributes:
unit_of_purchase:
blank: "can't be blank"