Permalink
Browse files

Update how data_fabric is initialized so it works with ActiveSupport'…

…s loading
  • Loading branch information...
1 parent 13d819f commit 58747399ae4767f1c2e9933f3937464c943f9306 @mperham mperham committed Feb 15, 2008
Showing with 6 additions and 4 deletions.
  1. +1 −3 init.rb
  2. +5 −1 lib/data_fabric.rb
View
@@ -1,3 +1 @@
-require 'data_fabric'
-
-ActiveRecord::Base.send(:include, DataFabric)
+DataFabric.init
View
@@ -36,6 +36,10 @@
# end
module DataFabric
+ def self.init
+ ActiveRecord::Base.send(:include, self)
+ end
+
def self.activate_shard(group, instance, &block)
ensure_setup
Thread.current[:shards][group.to_s] = instance.to_s
@@ -157,7 +161,7 @@ def raw_connection
unless already_connected_to? conn_name
@cached_connection = begin
config = ActiveRecord::Base.configurations[conn_name]
- raise ArgumentError, "Unknown database config: #{conn_name}" unless config
+ raise ArgumentError, "Unknown database config: #{conn_name}, have #{ActiveRecord::Base.configurations.inspect}" unless config
@model_class.establish_connection config
conn = @model_class.connection
# conn.verify! 0

0 comments on commit 5874739

Please sign in to comment.