Skip to content

Commit bceb736

Browse files
committed
Fix database selector docs
I had updated these docs in 770e12f when I added a generator for this file. These docs didn't get updated in that change.
1 parent 4ea0433 commit bceb736

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

activerecord/lib/active_record/middleware/database_selector.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,33 @@ module Middleware
1919
# that informs the application when to read from a primary or read from a
2020
# replica.
2121
#
22-
# To use the DatabaseSelector in your application with default settings add
23-
# the following options to your environment config:
22+
# To use the DatabaseSelector in your application with default settings,
23+
# run the provided generator.
2424
#
25-
# # This require is only necessary when using `rails new app --minimal`
26-
# require "active_support/core_ext/integer/time"
25+
# bin/rails g active_record:multi_db
2726
#
28-
# class Application < Rails::Application
27+
# This will create a file named +config/initializers/multi_db.rb+ with the
28+
# following contents:
29+
#
30+
# Rails.application.configure do
2931
# config.active_record.database_selector = { delay: 2.seconds }
3032
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
3133
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
3234
# end
3335
#
34-
# New applications will include these lines commented out in the production.rb.
36+
# Alternatively you can set the options in your environment config or
37+
# any other config file loaded on boot.
3538
#
3639
# The default behavior can be changed by setting the config options to a
3740
# custom class:
3841
#
3942
# config.active_record.database_selector = { delay: 2.seconds }
4043
# config.active_record.database_resolver = MyResolver
4144
# config.active_record.database_resolver_context = MyResolver::MySession
45+
#
46+
# Note: If you are using `rails new my_app --minimal` you will need to call
47+
# `require "active_support/core_ext/integer/time"` to load the libaries
48+
# for +Time+.
4249
class DatabaseSelector
4350
def initialize(app, resolver_klass = nil, context_klass = nil, options = {})
4451
@app = app

0 commit comments

Comments
 (0)