Revert "Merge pull request #37504 from utilum/no_implicit_conversion_of_nil"
This reverts commit4e105385d0
, reversing changes made to62b4383909
. The change in Ruby that made those changes required was reverted in8852fa8760
This commit is contained in:
parent
7c3e4409fd
commit
e67fdc5aeb
|
@ -280,7 +280,7 @@ module ActionController #:nodoc:
|
|||
|
||||
# Check for cross-origin JavaScript responses.
|
||||
def non_xhr_javascript_response? # :doc:
|
||||
media_type && %r(\A(?:text|application)/javascript).match?(media_type) && !request.xhr?
|
||||
%r(\A(?:text|application)/javascript).match?(media_type) && !request.xhr?
|
||||
end
|
||||
|
||||
AUTHENTICITY_TOKEN_LENGTH = 32
|
||||
|
|
|
@ -231,7 +231,7 @@ module Mime
|
|||
class InvalidMimeType < StandardError; end
|
||||
|
||||
def initialize(string, symbol = nil, synonyms = [])
|
||||
if string.nil? || ! MIME_REGEXP.match?(string)
|
||||
unless MIME_REGEXP.match?(string)
|
||||
raise InvalidMimeType, "#{string.inspect} is not a valid MIME type"
|
||||
end
|
||||
@symbol, @synonyms = symbol, synonyms
|
||||
|
|
|
@ -273,8 +273,7 @@ module ActionDispatch
|
|||
# (case-insensitive), which may need to be manually added depending on the
|
||||
# choice of JavaScript libraries and frameworks.
|
||||
def xml_http_request?
|
||||
header = get_header("HTTP_X_REQUESTED_WITH")
|
||||
header && /XMLHttpRequest/i.match?(header)
|
||||
/XMLHttpRequest/i.match?(get_header("HTTP_X_REQUESTED_WITH"))
|
||||
end
|
||||
alias :xhr? :xml_http_request?
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ module ActionDispatch
|
|||
missing_keys << key
|
||||
end
|
||||
else
|
||||
if parts[key].nil? || !/\A#{tests[key]}\Z/.match?(parts[key])
|
||||
unless /\A#{tests[key]}\Z/.match?(parts[key])
|
||||
missing_keys ||= []
|
||||
missing_keys << key
|
||||
end
|
||||
|
|
|
@ -346,7 +346,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
def split_to(to)
|
||||
if to && /#/.match?(to)
|
||||
if /#/.match?(to)
|
||||
to.split("#")
|
||||
else
|
||||
[]
|
||||
|
@ -355,7 +355,7 @@ module ActionDispatch
|
|||
|
||||
def add_controller_module(controller, modyoule)
|
||||
if modyoule && !controller.is_a?(Regexp)
|
||||
if controller && controller.to_s.start_with?("/")
|
||||
if %r{\A/}.match?(controller)
|
||||
controller[1..-1]
|
||||
else
|
||||
[modyoule, controller].compact.join("/")
|
||||
|
|
|
@ -280,11 +280,7 @@ module ActionView
|
|||
def _write_layout_method # :nodoc:
|
||||
silence_redefinition_of_method(:_layout)
|
||||
|
||||
prefixes = if _implied_layout_name && /\blayouts/.match?(_implied_layout_name)
|
||||
[]
|
||||
else
|
||||
["layouts"]
|
||||
end
|
||||
prefixes = /\blayouts/.match?(_implied_layout_name) ? [] : ["layouts"]
|
||||
default_behavior = "lookup_context.find_all('#{_implied_layout_name}', #{prefixes.inspect}, false, [], { formats: formats }).first || super"
|
||||
name_clause = if name
|
||||
default_behavior
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class EmailValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
if value.nil? || ! /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.match?(value)
|
||||
unless /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.match?(value)
|
||||
record.errors.add(attribute, message: options[:message] || "is not an email")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,9 +47,7 @@ module ActiveRecord
|
|||
set_callback :checkin, :after, :enable_lazy_transactions!
|
||||
|
||||
def self.type_cast_config_to_integer(config)
|
||||
if config.nil?
|
||||
config
|
||||
elsif config.is_a?(Integer)
|
||||
if config.is_a?(Integer)
|
||||
config
|
||||
elsif SIMPLE_INT.match?(config)
|
||||
config.to_i
|
||||
|
|
|
@ -162,7 +162,7 @@ module ActiveRecord
|
|||
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
|
||||
default, default_function = field[:Default], nil
|
||||
|
||||
if type_metadata.type == :datetime && default && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(default)
|
||||
if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(default)
|
||||
default, default_function = nil, default
|
||||
elsif type_metadata.extra == "DEFAULT_GENERATED"
|
||||
default = +"(#{default})" unless default.start_with?("(")
|
||||
|
|
|
@ -620,7 +620,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def has_default_function?(default_value, default)
|
||||
!default_value && default && %r{\w+\(.*\)|\(.*\)::\w+|CURRENT_DATE|CURRENT_TIMESTAMP}.match?(default)
|
||||
!default_value && %r{\w+\(.*\)|\(.*\)::\w+|CURRENT_DATE|CURRENT_TIMESTAMP}.match?(default)
|
||||
end
|
||||
|
||||
def load_additional_types(oids = nil)
|
||||
|
|
Loading…
Reference in New Issue