I have numerous models in my app/models folder. I\'d like to clean this folder up a little bit. Move models that belong to each other in subfolders. The problem is that by c
All the above answers didn't work for me. Somehow 'models' folder was loaded with subfolders, which resulted in 'Expected to contain ::.
Most of my subdirs were STI classes so I've moved them to app/models_sti//*. Then all I needed to do was to put in application.rb
#config.autoload_paths += Dir["#{Rails.root.to_s}/app/models/**/"]
# Loaded dynamically (cache_classes == false ?)
config.autoload_paths << Rails.root.join('app', 'models').to_s
config.autoload_paths += Dir["#{Rails.root.to_s}/app/models_sti/*"].find_all { |f| File.stat(f).directory? }
# Eager_load_paths - used only when cache_classes == true [rails spec says so]
config.eager_load_paths.delete_if do |path|
# If I didn't delete it from eager_load_paths I got errors even in develop
path == Rails.root.join('app', 'models_sti').to_s
end
config.eager_load_paths += config.autoload_paths