module ActionDispatch::Routing::Mapper::Resources

def apply_common_behavior_for(method, resources, options, &block)

def apply_common_behavior_for(method, resources, options, &block)
  if resources.length > 1
    resources.each { |r| public_send(method, r, options, &block) }
    return true
  end
  if options[:shallow]
    options.delete(:shallow)
    shallow do
      public_send(method, resources.pop, options, &block)
    end
    return true
  end
  if resource_scope?
    nested { public_send(method, resources.pop, options, &block) }
    return true
  end
  options.keys.each do |k|
    (options[:constraints] ||= {})[k] = options.delete(k) if options[k].is_a?(Regexp)
  end
  scope_options = options.slice!(*RESOURCE_OPTIONS)
  unless scope_options.empty?
    scope(scope_options) do
      public_send(method, resources.pop, options, &block)
    end
    return true
  end
  false
end