Skip to content

Commit 372c4ba

Browse files
committed
Handle Rails.env.blah? even if Rails isn't loaded.
1 parent 64ce90d commit 372c4ba

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/errplane/capistrano.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,22 @@
1313

1414
puts "Notifying Errplane of the deployment.."
1515
framework_env = fetch(:errplane_env, fetch(:rails_env, 'production'))
16-
load File.join(Dir.pwd, "config/initializers/errplane.rb")
16+
17+
unless defined?(Rails)
18+
class Rails
19+
@env = "production";
20+
def self.env; return self; end
21+
def self.env=(env); @env = env; end
22+
def self.to_s; @env; end
23+
def self.method_missing(m, *args, &block); return m.to_s == "#{@env}?"; end
24+
end
25+
Rails.env = framework_env
26+
end
27+
begin
28+
load File.join(Dir.pwd, "config/initializers/errplane.rb")
29+
rescue
30+
puts "Couldn't find default initializer for Errplane, continuing anyhow."
31+
end
1732

1833
Errplane.configuration.logger = Logger.new("/dev/null")
1934
Errplane.configuration.environment = framework_env

lib/errplane/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Errplane
2-
VERSION = "1.0.9"
2+
VERSION = "1.0.10"
33
end

0 commit comments

Comments
 (0)