Why ActiveRecord::Base.connected? is false, after calling establish_connection

I develop Sinatra application and use there ActiveRecord for working with database, but I encountered one problem. I wrote a test for a model and it breaks with

SQLite3::CantOpenException: unable to open database file

Connection to database is established in test_helper.rb with the following code:

Dir.chdir('..') do
  ActiveRecord::Base.establish_connection(db_config)
end

and ActiveRecord::Base.connected? get false. If I call User.find(:all) for example after connection establishment test will pass and ActiveRecord::Base.connected? will be true. Why? I don't understand.

10
задан Dmitry Maksimov 18 August 2010 в 18:27
поделиться