LoginSignup
0
0

More than 1 year has passed since last update.

Rails console で autoload のパスを確認する ( ActiveSupport::Dependencies.autoload_paths )

Last updated at Posted at 2022-06-30

コマンド

rails console で以下を実行

ActiveSupport::Dependencies.autoload_paths

実行例

irb(main):001:0> ActiveSupport::Dependencies.autoload_paths
=>
["/Users/yumainaura/example/app/channels",
 "/Users/yumainaura/example/app/controllers",
 "/Users/yumainaura/example/app/controllers/concerns",
 "/Users/yumainaura/example/app/helpers",
 "/Users/yumainaura/example/app/jobs",
 "/Users/yumainaura/example/app/mailers",
 "/Users/yumainaura/example/app/models",
 "/Users/yumainaura/example/app/models/concerns",
 "/Users/yumainaura/example/app/uploaders",
 "/Users/yumainaura/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionmailbox-7.0.2.4/app/controllers",
 "/Users/yumainaura/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionmailbox-7.0.2.4/app/jobs",
 "/Users/yumainaura/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionmailbox-7.0.2.4/app/models",
 "/Users/yumainaura/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-7.0.2.4/app/controllers",
 "/Users/yumainaura/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-7.0.2.4/app/controllers/concerns",
 "/Users/yumainaura/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-7.0.2.4/app/jobs",
 "/Users/yumainaura/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-7.0.2.4/app/models",
 "/Users/yumainaura/example/test/mailers/previews"]

autoloadの追加設定

config/application.rb などで設定する

require_relative "boot"

require "rails/all"

Bundler.require(*Rails.groups)

module Example
  class Application < Rails::Application
    config.load_defaults 7.0
    config.autoload_paths << "#{root}/app/uploaders"
  end
end

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0