I decided to write on this in the hope it will help someone else. I lost too much time on this problem.
I have a Rails application that I migrated from 3.0.3 to 3.0.9. Suddenly, all my tests were failing on my Media model with this error:
Could not find table 'media'
I went in the Rails console, and just typing Media was giving me this error instead of listing the attributes:
=> Media(Table doesn't exist)
What??? I checked my database, everything was fine. Looks like the pluralization does not work. And then, I type:
Ha haaaa….. that’s it. Rails must have new inflectors, and it does!
To fix this, we have two options:
- Force the table name in the Model
- Add an inflector of our own
I chose the second option since it would apply to my entire app (views as well). Just had to modify the inflections.rb initializer:
ActiveSupport::Inflector.inflections do |inflect| inflect.irregular 'media', 'medias' end
There you go. Hope it helps.