Issue with custom inflections in Ruby on Rails 3.0.3

不问归期 提交于 2019-12-02 11:49:21

I see several others having the same problem. Couldn't find an answer why this happens. So in the meantime you could just try this:

has_many :producciones_alternativas, :class_name => "ProduccionAlternativa"

I found another solution too. I added another rule on inflection.rb:

inflect.irregular('ProduccionAlternativa', 'ProduccionesAlternativas')
inflect.irregular('produccion_alternativa', 'producciones_alternativas')

At least, now it's working as I want. Thanx.

Your Fail is that you pluralized both words in has_many association. You used:

has_many :producciones_alternativas

but based on the class name ProduccionAlternativa the plural is produccion_alternativas because only the last word is pluralized! So this should work:

has_many :produccion_alternativas

To check the Plural of a word type "your_word".pluralize in the rails console!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!