跳至内容 跳至搜索
方法
B
L
R
S

实例公共方法

boot_application!()

# File railties/lib/rails/command/actions.rb, line 18
def boot_application!
  require_application!
  Rails.application.require_environment! if defined?(APP_PATH)
end

load_environment_config!()

# File railties/lib/rails/command/actions.rb, line 23
def load_environment_config!
  require_application!
  # Only run initializers that are in the :all group, which includes the
  # :load_environment_config initializer.
  Rails.application.initialize!(:_) if defined?(APP_PATH)
end

load_generators()

# File railties/lib/rails/command/actions.rb, line 36
def load_generators
  engine = ::Rails::Engine.find(ENGINE_ROOT)
  Rails::Generators.namespace = engine.railtie_namespace
  engine.load_generators
end

load_tasks()

# File railties/lib/rails/command/actions.rb, line 31
def load_tasks
  Rake.application.init("rails")
  Rake.application.load_rakefile
end

require_application!()

# File railties/lib/rails/command/actions.rb, line 13
def require_application!
  require ENGINE_PATH if defined?(ENGINE_PATH)
  require APP_PATH if defined?(APP_PATH)
end

set_application_directory!()

如果当前目录中没有 config.ru 文件,则更改为应用程序的路径。这允许我们从其他目录运行 rails server,但仍然获取主 config.ru 并正确设置 tmp 目录。

# File railties/lib/rails/command/actions.rb, line 9
def set_application_directory!
  Dir.chdir(File.expand_path("../..", APP_PATH)) unless File.exist?(File.expand_path("config.ru"))
end