instance method require_dependency

Ruby on Rails 7.2.3.2

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3.2 v8.0.5.1 v8.1.3.1 edge

Signature

require_dependency(filename)

Warning: This method is obsolete. The semantics of the autoloader match Ruby’s and you do not need to be defensive with load order anymore. Just refer to classes and modules normally.

Engines that do not control the mode in which their parent application runs should call require_dependency where needed in case the runtime mode is :classic.

Parameters

filename req
Source
# File activesupport/lib/active_support/dependencies/require_dependency.rb, line 11
  def require_dependency(filename)
    filename = filename.to_path if filename.respond_to?(:to_path)

    unless filename.is_a?(String)
      raise ArgumentError, "the file name must be either a String or implement #to_path -- you passed #{filename.inspect}"
    end

    if abspath = ActiveSupport::Dependencies.search_for_file(filename)
      require abspath
    else
      require filename
    end
  end

Defined in activesupport/lib/active_support/dependencies/require_dependency.rb line 11 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Dependencies::RequireDependency

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close