I have a model Sport
. Using single table inheritance I have 2 other models, Cricket
and Football
so that
class Cricket < Sport and class Football < Sport
I put these two models in a subfolder inside models directory called sports. I added the type column to Sport
and put the value as Cricket
or Football
, whatever was appropriate. Also, I was able to create objects using Cricket.new
or Football.new
.
This structure works fine till Rails 3.2.6.
But now with Rails 3.2.11, any model file inside a subfolder has to be modularised. So, it looks like this now:
module Sports
class Cricket < Sport
Now, rails is not able to load the class Cricket
or Football
alone. So, Cricket.new
or Football.new
does not work. If I do Sports::Cricket.new
, then it is a problem for me because the type column has to be the class name, i.e. Sports::Cricket
.
What should I do in Rails 3.2.11 for single table inheritance to work? I don't want to put values like Sports::Cricket
in my type column.
Also, I do not want to remove the subdirectory structure.