active_record_shards 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -133,7 +133,7 @@ module ActiveRecordShards
133
133
  end
134
134
 
135
135
  def shard_env
136
- @shard_env = defined?(Rails.env) ? Rails.env : RAILS_ENV
136
+ ActiveRecordShards.rails_env
137
137
  end
138
138
 
139
139
  def establish_shard_connection
@@ -30,7 +30,7 @@ module ActiveRecordShards
30
30
  end
31
31
 
32
32
  def shard_name(klass = nil, try_slave = true)
33
- s = "#{RAILS_ENV}"
33
+ s = ActiveRecordShards.rails_env.dup
34
34
  if the_shard = shard(klass)
35
35
  s << '_shard_'
36
36
  s << the_shard
@@ -45,4 +45,4 @@ module ActiveRecordShards
45
45
  {:shard => @shard, :slave => @on_slave}
46
46
  end
47
47
  end
48
- end
48
+ end
@@ -12,3 +12,9 @@ ActiveRecord::Base.extend(ActiveRecordShards::ConfigurationParser)
12
12
  ActiveRecord::Base.extend(ActiveRecordShards::Model)
13
13
  ActiveRecord::Base.extend(ActiveRecordShards::ConnectionSwitcher)
14
14
  ActiveRecord::Associations::AssociationCollection.send(:include, ActiveRecordShards::AssociationCollectionConnectionSelection)
15
+
16
+ module ActiveRecordShards
17
+ def self.rails_env
18
+ Kernel.const_defined?(:Rails) ? Rails.env : RAILS_ENV
19
+ end
20
+ end