簡體   English   中英

Rails生成模型不使用變形規則

[英]Rails Generate Model not using inflection rule

我正在嘗試在Rails 5.1中以及運行時生成“狀態”模型

rails generate model status

我懂了

The model name 's' was recognized as a plural, using the singular '' instead. Override with --force-plural or setup custom inflection rules for this noun before running the generator.

然后,我在config / initializers / inflections.rb中添加了一條新規則

ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.irregular 'status', 'statuses'
end

再次運行命令,我仍然收到錯誤。

我想念什么?

也許您可以將名稱更改為州,所以復數為州

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM