简体   繁体   English

Rails生成模型不使用变形规则

[英]Rails Generate Model not using inflection rule

I'm trying to generate a 'Status' model in Rails 5.1 and when I run 我正在尝试在Rails 5.1中以及运行时生成“状态”模型

rails generate model status

I get 我懂了

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.

I then added a new rule in config/initializers/inflections.rb 然后,我在config / initializers / inflections.rb中添加了一条新规则

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

ran the command again and I still get the error. 再次运行命令,我仍然收到错误。

What am I missing? 我想念什么?

也许您可以将名称更改为州,所以复数为州

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM