I am not sure whether this is a bug or if I have totally gone mad.
I have a remote database and I am able to make queries on all tables except tables which end with the letter “y”
My model: ox_stats_country.rb
class OxStatsCountry < ActiveRecord::Base
establish_connection :openx
self.abstract_class = true
end
The table name on the remote/legacy database is “ox_stats_country”.
When I try to query something in the rails console like this: “OxStatsCountry.find(1)”
I get the following error:
ActiveRecord::StatementInvalid: Mysql2::Error: Table ‘openx.ox_stats_countries’ doesn’t exist: SHOW FIELDS FROM
ox_stats_countries
As you can see, it pluralizes automatically the table name and hence is not able to find it. I have the same problem with the table name “agency”. Yet with all the other tables (not ending with the letter “y”) everything works fine.
Is this a bug of the mysql2 adapter? If so, where would I file such bug? Do you have any ideas on how to solve this? I am newbish to RoR and programming in general so I would appreciate any kind of help.
Thanks for your time… Uli
Well, ActiveRecord looks for plural table names by default. Your table names should be plural (agencies, for example). However, you can override the table name with this in your model: