I have a file which looks like this
#app/services/account/authenticate/base.rbmodule Account module Authenticate AuthenticateError = Class.new(StandardError) class Base < ::Account::Base def self.call(*attrs) raise NotImplementedError end end endend
Now when I will run the code from rails c
I have an error
> ::Account::Authenticate::AuthenticateError=> NameError (uninitialized constant Account::Authenticate::AuthenticateError)> ::Account::Authenticate.constants=> [:Base, :ViaToken]
So rails doesn't see AuthenticateError class. But when I will create a nested class from this folder like
=> Account::Authenticate::ViaToken> ::Account::Authenticate.constants=> [:Base, :AuthenticateError, :ViaToken]
AuthenticateError class is now visible
> ::Account::Authenticate::AuthenticateError=> Account::Authenticate::AuthenticateError
The solution for this problem is to create a separate file authenticate_error.rb which will work from the beginning but this solution is not ideal for me. Is there any solution to preload all classes or smth?
(Ruby 2.6 with Rails 6.0.0.rc2)