README.md in octoshark-0.0.2 vs README.md in octoshark-0.0.3
- old
+ new
@@ -29,11 +29,11 @@
## Usage
Specify the connections for Octoshark to manage. This is usually done in an app initializer.
```ruby
-Octoshark.setup({
+Octoshark.configure({
db1: { adapter: "sqlite3", database: "db/db1.sqlite" },
db2: { adapter: "sqlite3", database: "db/db2.sqlite" }
})
```
@@ -98,9 +98,15 @@
When we want to do something in the slave database with all ActiveRecord models, then we need to add Octoshark's current or default connection to all models, either by overriding `ActiveRecord:Base.connection` or using a module that we include in all models.
```ruby
class ActiveRecord::Base
def self.connection
+ # Some rake tasks like `rake db:create` does not load initializers,
+ # and because we're overriding ActiveRecord::Base.connection,
+ # we need to make sure Octoshark is configured before using it.
+ Octoshark.configure(configs) unless Octoshark.configured?
+
+ # Return the current connection (from with_connection block) or default one
Octoshark.current_or_default_connection
end
end
```