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) ...@@ -39,7 +39,7 @@ def initialize(name)
class PendingMigrationError < MigrationError#:nodoc: class PendingMigrationError < MigrationError#:nodoc:
def initialize 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}") super("Migrations are pending. To resolve this issue, run:\n\n\tbin/rake db:migrate RAILS_ENV=#{::Rails.env}")
else else
super("Migrations are pending. To resolve this issue, run:\n\n\tbin/rake db:migrate") super("Migrations are pending. To resolve this issue, run:\n\n\tbin/rake db:migrate")
......
...@@ -3,7 +3,7 @@ module Kernel ...@@ -3,7 +3,7 @@ module Kernel
# Starts a debugging session if the +debugger+ gem has been loaded (call rails server --debugger to load it). # Starts a debugging session if the +debugger+ gem has been loaded (call rails server --debugger to load it).
def debugger 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" 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 end
alias breakpoint debugger unless respond_to?(:breakpoint) alias breakpoint debugger unless respond_to?(:breakpoint)
end end
......
...@@ -20,7 +20,7 @@ class Deprecation ...@@ -20,7 +20,7 @@ class Deprecation
log: ->(message, callstack) { log: ->(message, callstack) {
logger = logger =
if defined?(Rails) && Rails.logger if defined?(Rails.logger) && Rails.logger
Rails.logger Rails.logger
else else
require 'active_support/logger' require 'active_support/logger'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册