Despite doing Rails as it is, I'm addicted to uninitialized constant errors, so I'll put together a checklist here.
The following three items should be checked.
I will write the details below.
If the following class exists, the file name must be qiita_user.rb.
class QiitaUser
  def hoge
  end
end
If there is a nested class in the following module, the path will be something like ** / v1 / auth / user.rb.
class V1::Auth::User
end
OR
module V1
  module Auth
    class User
    end
  end
end
If you want to add a folder other than the Rails default folder, you need to define the path to the added folder in autoload path.
Suppose you add ʻapp / lib / hoge / foo.rb. In this case, you need to add the autoload path to config / application.rb` in the following form.
module App
  class Application < Rails::Application
    #abridgement
    
    config.autoload_paths += Dir.glob("#{config.root}/app/lib")
  end
end
        Recommended Posts