You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
I'm using rails 4.2 with pg database in a new project and used the rspec setup from the book, expect I've upgraded selenium-webdriver to the last ~> 2.45.0. But there is a problem with the shared db connection code.
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
This gives me a PG connection error:
PG::ConnectionBad: connection is closed: (ActiveRecord::StatementInvalid)
SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','m') -- (r)elation/table, (v)iew, (m)aterialized view
AND c.relname = 'schema_migrations'
AND n.nspname = ANY (current_schemas(false))
Now I partially understand why this shared connection is done(correct me if I'm wrong, capybara with js driver and the app are in different threads so they are not sharing the same db connection). Now if I remove the last line from the shared_db_connection file and put it in a background block like this
background do
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
end
or put this line in rails_helper.rb the tests run without error. Now I wanna ask if this has the same effect as the one in the tutorial and what may be the reasons for this error?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm using rails 4.2 with pg database in a new project and used the rspec setup from the book, expect I've upgraded selenium-webdriver to the last ~> 2.45.0. But there is a problem with the shared db connection code.
This gives me a PG connection error:
Now I partially understand why this shared connection is done(correct me if I'm wrong, capybara with js driver and the app are in different threads so they are not sharing the same db connection). Now if I remove the last line from the shared_db_connection file and put it in a background block like this
or put this line in rails_helper.rb the tests run without error. Now I wanna ask if this has the same effect as the one in the tutorial and what may be the reasons for this error?
The text was updated successfully, but these errors were encountered: