I have a rails application which uses two databases in production environment, Users
and Process
. The Users
model uses this customized ActiveRecord
class:
class UserActiveRecord < ActiveRecord::Base
establish_connection "#{Rails.env}_users_db"
end
class User < UserActiveRecord
...
Notice that the connection to a specific database is established depending on the environment. To simplify things, in the testing environment I have a single database with all the tables from the two production databases, and my database.yml
file looks something like this:
test:
adapter: postgresql
database: db_test
host: localhost
pool: ...
timeout: ...
username: ...
password: ...
test_users_db:
adapter: postgresql
database: db_test <--- Notice that this is the same database only in test env
host: localhost
pool: ...
timeout: ...
username: ...
password: ...
The application runs fine in production, but when I run any test that refers to the User
class, the test blocks at the exact point where User
is used and nothing happens, it doesn't show any error, it doesn't exit, it just keeps waiting.
I double-checked and the table USERS
exists in the test database, in fact if I delete it manually I get the error that the table doesn't exists and when I create it again I get the same behavior reported in the previous paragraph.
I don't have a clue why this is happening, any idea on how can I solve this issue? or how can I debug it so that I can get to the root of the problem? Any additional details will be posted as required.
Aucun commentaire:
Enregistrer un commentaire