我正在使用Rails(3.0.1)并在initializers / inflections中使用以下代码.rb
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular('nursery', 'nurseries')
end
从控制台我得到:
"nursery".pluralize => "nurseries"
"nurseries".singularize => "nurseries"
我应该得到:
"nurseries".singularize => "nursery"
有什么想法吗?
答案 0 :(得分:5)
我找到了解决办法!
将以下代码放在initializers / inflections.rb
中ActiveSupport::Inflector.inflections do |inflect|
inflect.clear :uncountables
inflect.irregular 'nursery', 'nurseries'
end