Hi guys,
I was writing a ruby on rails app and while doing the test cases, I came across a situation where the test cases failed with an error
uninitialized constant User::Leafe
Now, there is no typo in my code. I have a User model and a User can have many Leaves. So I had added associations to the rails User model.
has_many :leaves, :dependent => :destroy
While searching around Stackoverflow, I found this solution here
It details that Inflections in rails assumes that singular form of “leaves” is “leaf”. It also detailed the solution as adding an irregular inflection to the inflection initialisers to solve this.
So, add the following to the file, config/initializers/inflections.rb
ActiveSupport::Inflector.inflections do |inflect| inflect.irregular 'opening_leave', 'opening_leaves' end
This fixed the problem. It is weird that Ruby on Rails does this, but more digging lead me to a documentation page here
This states that due to the fact that legacy applications may still use errant inflections, new patches that fixes errors in conversions done by the “inflector” in rails are not being done. For every error we observe, we have to provide the correct inflection rule in our ruby on rails app.