Skip to content

Commit

Permalink
Rails 7 primary is now AR::Base
Browse files Browse the repository at this point in the history
Fixes deprecation in rails 6.1:
"primary"` has been deprecated as the `connection_specification_name` for `ActiveRecord::Base` in favor of using `"ActiveRecord::Base"`. This change affects calls to `ActiveRecord::Base.connection_handler.retrieve_connection` and `ActiveRecord::Base.connection_han
dler.remove_connection`. If you're calling these methods with `"primary"`, please switch to `"ActiveRecord::Base".
  • Loading branch information
jrafanie committed Jan 19, 2024
1 parent 430924f commit 119559c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@
# Necessary because you currently cannot specify the
# connection name for ActiveRecord::Schema, which we use
# in tests to reset db schema for different RHEV versions.
c.connection_specification_name = 'primary' if ActiveRecord::VERSION::MAJOR >= 5
case ActiveRecord::VERSION::MAJOR
when 7
c.connection_specification_name = 'ActiveRecord::Base'
else
c.connection_specification_name = 'primary'
end
end
ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"

Expand Down

0 comments on commit 119559c

Please sign in to comment.