Do not check only for the Rails constant

This constant may be define for auxiliar gems like rails-html-sanitizer
and these methods call will fail.
上级 8a1c3476
......@@ -39,7 +39,7 @@ def initialize(name)
class PendingMigrationError < MigrationError#:nodoc:
def initialize
if defined?(Rails)
if defined?(Rails.env)
super("Migrations are pending. To resolve this issue, run:\n\n\tbin/rake db:migrate RAILS_ENV=#{::Rails.env}")
else
super("Migrations are pending. To resolve this issue, run:\n\n\tbin/rake db:migrate")
......
......@@ -3,7 +3,7 @@ module Kernel
# Starts a debugging session if the +debugger+ gem has been loaded (call rails server --debugger to load it).
def debugger
message = "\n***** Debugger requested, but was not available (ensure the debugger gem is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
defined?(Rails.logger) ? Rails.logger.info(message) : $stderr.puts(message)
end
alias breakpoint debugger unless respond_to?(:breakpoint)
end
......
......@@ -20,7 +20,7 @@ class Deprecation
log: ->(message, callstack) {
logger =
if defined?(Rails) && Rails.logger
if defined?(Rails.logger) && Rails.logger
Rails.logger
else
require 'active_support/logger'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册