README.md in octoshark-0.5.1 vs README.md in octoshark-0.6.0
- old
+ new
@@ -107,24 +107,26 @@
To tell an ActiveRecord model to use the Octoshark connection we can override the `Model.connection` method.
```ruby
class Post < ActiveRecord::Base
- def self.connection
- CONN_MANAGER.current_connection
- end
-end
-```
+ class << self
+ def connection
+ CONN_MANAGER.current_connection
+ end
-Alternatively, we can extract it as a module and include in multiple models.
+ # For Rails 7.2+ we need to override the following methods too:
-```ruby
-module ShardingModel
- extend ActiveSupport::Concern
+ def lease_connection
+ connection
+ end
- module ClassMethods
- def connection
- CONN_MANAGER.current_connection
+ def with_connection
+ yield connection
+ end
+
+ def schema_cache
+ connection.schema_cache
end
end
end
```