Undefined method "load_paths" for ActiveSupport::Dependencies:Module Error

I’m writing a Rails plugin from scratch and recently generating models
inside it.
In fact, i’m trying to follow the guide from

so i used the following code taken from this site in order to make the
models appear like files in the main app directory (as it was said)

this is the code:
%w{ models }.each do |dir|
path = File.join(File.dirname(FILE), ‘app’, dir)
$LOAD_PATH << path
ActiveSupport::Dependencies.load_paths << path
ActiveSupport::Dependencies.load_once_paths.delete(path)
end


When i run ‘rails console ’ this error appear
undefined method `load_paths’ for ActiveSupport::Dependencies:Module
(NoMethodError)

thanks for your help

I did a bit of digging around, and it turns out that load_paths and
load_once_paths have been deprecated, meaning they are no longer being
used.

Changing the lines:

ActiveSupport::Dependencies.load_paths << path
ActiveSupport::Dependencies.load_once_paths.delete(path)

to:

ActiveSupport::Dependencies.autoload_paths << path
ActiveSupport::Dependencies.autoload_once_paths.delete(path)

Fixes the problem for me.