rails_multisite 2.0.4 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_multisite might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b3582604a5da7995f373bf26865600897c13b758
4
- data.tar.gz: 6625a29d66a9873ed4f041e38d72525eb9c184ed
2
+ SHA256:
3
+ metadata.gz: 2dcf0982fa73681b77ead88c24501dd8a8dba972b5bd23ecbc3779095dc53168
4
+ data.tar.gz: 985413ce023cebd3e215b9a961547fa4e2643667dacce3136469236d35ad6ccb
5
5
  SHA512:
6
- metadata.gz: cef249afb34bdcbbf3ba0eee36e1ce487d557fd7c6d4a70766359e697c5a75b34a53d9e01b2a5fca631e2759a12c456c6b3296b97c97d2696f962ed5d4682f56
7
- data.tar.gz: 1d99c6c7a0ec03bcc29ee5174dcf30d6230853ae717ada13171ee0566964d57d3b03c925c3c4bac9c299792f8fbf4287a4080fae42a76f0a8d74898a803224d5
6
+ metadata.gz: 4a459dc64ff1a9396637e74547fc72c4619c5314a919ef906b54cd94c17d5bdb9042daab13fc04e1be85c1e367030933ac8d40585ba83827cd3f3418155e3545
7
+ data.tar.gz: e4f77a94d8e91f38c31142175835eb16884d7e5b5f6bcfa4c55c621980f310c48bea4123fd930b50a69f2cb7e0a887154fd2c8210d6a811acc5faffeeb50cb26
data/README.md CHANGED
@@ -71,6 +71,30 @@ RailsMultisite::ConnectionManagement.each_connection(threads: 5) do |db|
71
71
  end
72
72
  ```
73
73
 
74
+ ### Usage with Rails
75
+
76
+ #### `RAILS_DB` Environment Variable
77
+
78
+ When working with a Rails application, you can specify the DB that you'll like to work with by specifying the `RAILS_DB` ENV variable.
79
+
80
+ ```
81
+ # config/multisite.yml
82
+
83
+ db_one:
84
+ adapter: ...
85
+ database: some_database_1
86
+
87
+ db_two:
88
+ adapater: ...
89
+ database: some_database_2
90
+ ```
91
+
92
+ To get a Rails console that is connected to `some_database_1` database:
93
+
94
+ ```
95
+ RAILS_ENV=db_one rails console
96
+ ```
97
+
74
98
 
75
99
  ## Contributing
76
100
 
@@ -160,10 +160,14 @@ module RailsMultisite
160
160
  def establish_connection(opts)
161
161
  opts[:db] = opts[:db].to_s
162
162
 
163
- spec = connection_spec(opts)
164
- if (!spec && opts[:raise_on_missing])
165
- raise "ERROR: #{opts[:db]} not found!"
163
+ if opts[:db] != DEFAULT
164
+ spec = connection_spec(opts)
165
+
166
+ if (!spec && opts[:raise_on_missing])
167
+ raise "ERROR: #{opts[:db]} not found!"
168
+ end
166
169
  end
170
+
167
171
  spec ||= @default_spec
168
172
  handler = nil
169
173
  if spec != @default_spec
@@ -308,13 +312,13 @@ module RailsMultisite
308
312
 
309
313
  private
310
314
 
311
- def handler_establish_connection(handler, spec)
312
- if Rails::VERSION::MAJOR >= 5
313
- handler.establish_connection(spec.config)
314
- else
315
- handler.establish_connection(ActiveRecord::Base, spec)
316
- end
315
+ def handler_establish_connection(handler, spec)
316
+ if Rails::VERSION::MAJOR >= 5
317
+ handler.establish_connection(spec.config)
318
+ else
319
+ handler.establish_connection(ActiveRecord::Base, spec)
317
320
  end
321
+ end
318
322
 
319
323
  end
320
324
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  module RailsMultisite
4
- VERSION = "2.0.4"
4
+ VERSION = "2.0.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_multisite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-12 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
- rubygems_version: 2.6.13
89
+ rubygems_version: 2.7.6
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Multi tenancy support for Rails